Home  >  Q&A  >  body text

字符编码 - windows7下c++字符串是gbk编码?还是unicode?

win7控制台的编码好像是gbk 控制台输出中文不会乱码 那么win7下c++的编码是gbk吗

还有VS里面的项目有个 使用unicode字符集和多字节字符集的选择 该怎么选择?

PHPzPHPz2714 days ago541

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 12:04:36

    Whatever encoding you choose to use will be used when compiled, and it has nothing to do with the console.

    Now of course it is recommended to use the Unicode character set. Multi-byte character sets refer to GBK** first-class character sets (DBCS).

    I have written an article about coding issues, you can have a brief understanding. Character encoding: from ASCII to UTF

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 12:04:36

    In terms of vs
    (under the Chinese system) ordinary strings are compiled into gbk
    After wide strings are compiled into utf16

    After using #pragma execution_character_set("utf-8"), the compiled version is utf8

    Multi-byte and unicode affect the type of TCHAR. In a multi-byte environment, TCHAR is equivalent to char. In a unicode environment, TCHAR is wchar_t. In addition, there are win32 api calls. In the multi-byte environment, the interface ending with a is called, and in the unicode environment, the native unicode interface is called. Since the internal implementation of the interface ending in a is to convert multi-bytes into unicode and then call the unicode interface, it is best to choose the unicode environment if there are no special requirements.

    reply
    0
  • Cancelreply