gpt4 book ai didi

c++ - 在 C++ 中使用 UNICODE 字符值

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:05:42 36 4
gpt4 key购买 nike

如何在 C++ 中使用 unicode?我知道 wchar_twchar_t* 但我想知道如何仅使用 Unicode 值来分配值,类似于通过将变量等同于来分配字符的方式ASCII 值:

char a = 92;

我正在使用 MinGW 编译器,如果它有所作为的话。

最佳答案

它可以很简单:

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");

关于c++ - 在 C++ 中使用 UNICODE 字符值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7571907/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com