Last active
December 15, 2017 04:32
-
-
Save ityuhui/0dabd1d8e210f3b3ba99 to your computer and use it in GitHub Desktop.
Chinese string for C++/C++中文字符串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <locale> | |
int main() | |
{ | |
wchar_t *wst = L"你好"; | |
std::cout << wcslen(wst) << std::endl; | |
std::wcout.imbue(std::locale("chs")); | |
std::wcout << wst << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
有一个小问题
当使用非中文版本的Windows时,需要切换代码页
system("chcp 936");