question

RobertPhillips-7975 avatar image
0 Votes"
RobertPhillips-7975 asked DavidLowndes-6766 commented

VS2019 C++ Compiler Appears to Generate Incorrect Unicode Characters

Hi,

I have a simple desktop application project in C++ WINAPI using all the default settings provided by VS2019. It uses wcsncpy_s() to load a string variable of type wchar_t with a literal string and then textout() to write this string to the screen. Standard ASCII characters are fine, but I also want to display the character Omega which has the unicode code value of 3A9 which I enter as per the sample below. However, what actually appears is not this character, but something different. I have checked tha the project properties (Configuration Properties > Advanced > Character Set are set to Use Unicode Character Set. Needless to say I've spent considerable time researching this and trying out the various suggestions but no solution has turned up so far. Trying character codes at random, it seems that the compiler can generate characters outside the basic ASCII set, for example it is possible to get a 'a' + umlaut or something like that. I suspect compiler may be outputting UTF-8 character set. Does anyone have any suggestions please?

Example

wcsncpy_s(TargetString, MAX_LOADSTRING, L"\x039A", MAX_LOADSTRING); // MAX_LOADSTRING is declared as 100

Amongst many other things have also tried but without success.

wcsncpy_s(TargetString, MAX_LOADSTRING, L"\u039A", MAX_LOADSTRING); // MAX_LOADSTRING is declared as 100

Thanks

c++
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

your code uses 039A, not 03A9.

1 Vote 1 ·

0 Answers