开发者

C++ encoding macro

Is the开发者_如何学Cre a macro that tells you what encoding C++ is using for its wchar_t type? I am currently stuck to GNU and clang. I am guessing UTF32 because my wchar_t has a size of 4 bytes. Although it could be UTF-16, it also uses 4 bytes for some code-points.

But then there is still the problem of UCS-4 or UTF-32LE or UTF-32BE.

Any help/expertise on this topic?


wchar_t is implementation specific. It is not bound any specific encoding. If you are on a platform where wchar_t is 16 bits then it simply does not support UTF32 for example.

Encoding (UTF8, UTF32) and storage (wchar_t) are different things.


There is no such macro in C++. In C99, there is macro STDC_ISO_10646 to indicate that wchar_t is Unicode. In C++, encoding of characters stored in wchar_t depends on locale and it is implementation-defined feature. In other words, you need to consult documentation of the C++ implementation you use to see see what wchar_t is associated with each locale.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜