c++
中的
char
内存为 1 字节
,但大多数 unicode
字符需要 2字节
。
这是否意味着 unicode
不能存储在 c++
中的 characters
中?
最佳答案
no char
不是唯一的。如果您使用的是 Windows,则有 wchar_t
( WCHAR
),或者通常认为 short
也是 2 字节,但这更多的是您想要实现和使用的方式它,协议(protocol)例如:
#if !defined(_NATIVE_WCHAR_T_DEFINED)
typedef unsigned short WCHAR;
#else
typedef wchar_t WCHAR;
#endif
WCHAR* strDemo = L"consider the L";
但是你需要在网络上挖掘更多。它们也称为多字节字符串,因此在您的搜索中请考虑这一点。
例如:
就像更通用的老式跨平台 BSD 方式一样:
https://www.freebsd.org/cgi/man.cgi?query=multibyte&apropos=0&sektion=0&format=html
http://utf8everywhere.org. and do not miss this
由于您首先提出了这个问题,我认为您应该了解 boost 也是。
关于c++ - 在 C++ 字符中存储 unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47375068/