开发者

assigning chinese as DBCS

开发者 https://www.devze.com 2023-04-05 04:09 出处:网络
In my code I can do: wchar_t *s = L\"...some chinese/japanese/etc string..\"; and this works okay. but if I do:

In my code I can do:

wchar_t *s = L"...some chinese/japanese/etc string..";

and this works okay. but if I do:

char *s = "...some chinese/japanese/etc string..."

I end up with s assigned to "???????" (not a display problem, there are actual question marks in the value).

Given that I'm on a US/1252 Wi开发者_开发知识库n 7 (VS2010) and Unicode-compiled apps, how do I create a MBCS chinese string given a constant string literal? I do not want it to be unicode, but rather the MBCS representation of the chinese characters.

So far the only way I've been able to do it is use the unicode version and convert it to MBCS using WideCharToMultiByte. Do I really need to do that, or enter it as a byte array?


Yes, you really do need to do that. There are no MBCS string literals in C++.

(In theory you could do something like char *s = "...\xa7\f6\d5..." with the right bytes, but that would be difficult to write and read.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号