I have to use some char16-wide strings for uefi programming. How can I initialize them easily? CHAR8 is easy:
CHAR8 *Str = "yehaw\0";
CHAR16 meanwhile is hard working that way, therefore I chose this initialization:
CHAR16 *Str;
Str = AllocatePool(6*2); //AllocatePool allocates bytewise
Str = ('y','e','h','a','w','\o');
So question is what would be the right and easiest way to initialize CHAR16 strings?
If you have the c standard library and are using a conformant C/C++ compiler, typically prefixing a string with L works for declared strings.As in :
CHAR16 *Str = L"yehaw";
works. However, why not use the ubiquitously accepted type of
wchar_t
?
Try this
CHAR16 *Str = u"yehaw\0";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With