开发者

Using UNICODE character values in C++

How do you use unicode in C++ ? Im aware of wchar_t and wchar_t* but I want to know how you can assign value using only Unicode Values, similar to the way a character can be assigned by equating 开发者_如何学Gothe variable to the ASCII value:

char a = 92;

Im uysing the MinGW compiler, if it makes a difference.


It can be as simple as:

wchar_t a=L'a';
wchar_t hello_world[]=L"Hello World";

// Or if you really want it to be (old school) C++ and not C

std::wstring s(L"Hello World");

// Or if you want to (be bleeding edge and) use C++11

std::u16string s16(u"Hello World");
std::u32string s32(U"Hello World for the ∞ᵗʰ time");


Exactly the same way:

wchar_t a = 97;
wchar_t xi = 0x03be; // ξ
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜