Failed to show `` (UTF-16 character) in wxWidgets (C++)

Viewed 95

I am using wxWidgets with Visual Studio 2022 (C++) to develop Windows application. I wish to display in the window, but as I tried using various fonts with the following code:

std::string fonts_name[8] = {"Calibri Light", "Calibri", "Cambria Math", "Cambria", "Candara Light", "Candara", "Consolas", "DFKai-SB"};
// ...
stat_txt_test = new wxStaticText*[8];
for (long long i = 0; i != 8; ++i) {
    stat_txt_test[i] = new wxStaticText(this, (long long)1000 + i, "", wxPoint(i * 15, i * 15), wxSize(10, 10), wxTE_READONLY);
    stat_txt_test[i]->SetFont(fonts[i]);
}

I only got screenshot.

However, if I use "a" (ascii character) instead, the result is enter image description here, which is as expected.

Now I am guessing that UTF-16 does not work well in my code. However, Chinese characters worked very well. This is the unicode of .

How should I modify my code in order to get this job done?

My attempts

"\x1D465" does not work and I got the following message and failure to build:

error C2022: '119909': too big for character "\xD835\xDC65" does not work (just a wild guess to use two characters to represent this character).

Any help will be appreciated. Thank you!

1 Answers

As shown in the wxWidget's documentation, the correct way would be as shown below:

//---------------------------------------vvvvvvvvv---->changed to u instead of x
label = new wxStaticText(this, wxID_ANY, L"\u0078");

or

label = new wxStaticText(this, wxID_ANY, L"\U0001D465");
Related