Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UEFI programming: How to Initialize a CHAR16 Unicode String?

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?

like image 502
Flitzpiepe Avatar asked Sep 11 '25 16:09

Flitzpiepe


2 Answers

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

?

like image 156
Jonathan Avatar answered Sep 13 '25 05:09

Jonathan


Try this

CHAR16 *Str = u"yehaw\0";
like image 25
Yann Justdohit Avatar answered Sep 13 '25 07:09

Yann Justdohit