2026-05-06 3:22 AM
Hello,
I've tried to reinterpret a char16_t string (specifically u"Hello")
to UnicodeChar* using
reinterpret_cast<const Unicode::UnicodeChar*>
they are the same ?
What is the difference between them ?
Solved! Go to Solution.
2026-05-11 6:56 AM
Hello @MauFanGilaMedical ,
If you intend to show the text in a textArea, you don't need to use the reinterpret_cast :
char16_t text[] = u"Hello";
// This works
#if 1
Unicode::UnicodeChar *tgfxStr = reinterpret_cast<Unicode::UnicodeChar *>(text);
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", tgfxStr);
#else
// This also works
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", text);
#endif
2026-05-06 5:23 AM
I would not be surprised if it is connected to when TouchGFX was conceived - meaning pre-C++11 standard times, when char16_t was introduced. And/Or Unicode::UnicodeChar is simply easier to use.
2026-05-08 2:45 AM
don't know
2026-05-11 6:56 AM
Hello @MauFanGilaMedical ,
If you intend to show the text in a textArea, you don't need to use the reinterpret_cast :
char16_t text[] = u"Hello";
// This works
#if 1
Unicode::UnicodeChar *tgfxStr = reinterpret_cast<Unicode::UnicodeChar *>(text);
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", tgfxStr);
#else
// This also works
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", text);
#endif