Skip to content

Instantly share code, notes, and snippets.

@ityuhui
Last active December 15, 2017 04:32
Show Gist options
  • Save ityuhui/0dabd1d8e210f3b3ba99 to your computer and use it in GitHub Desktop.
Save ityuhui/0dabd1d8e210f3b3ba99 to your computer and use it in GitHub Desktop.
Chinese string for C++/C++中文字符串
#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;
}
@HanzhouTang
Copy link

HanzhouTang commented Dec 15, 2017

有一个小问题
当使用非中文版本的Windows时,需要切换代码页
system("chcp 936");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment