C/C++用Unicode保存字符并输出

汉字的unicode编码可以在 http://bianma.supfree.net/sos.asp?id=3417查询;
GBK编码: D5C5
unicode编码: 5F20 
十进制unicode: 24352
                       
调试程序时可以查看到内存中“张”的值为 5f20 。这正是“张” Unicode编码,在使用这个方法之前,把“张”赋值给字符变量,将保存“张”的GBK编码 D5C5,而不是值为 5f20 的 Unicode编码。

C/C++ <wbr>用Unicode保存字符并输出

#include"stdlib.h"
#include"stdio.h"
#include"wchar.h"
#include"locale.h"

int main()
{
   setlocale(LC_ALL,""); 
   wchar_t wt=L'张';
    wprintf(L"%c\n",wt); //输出wt(单个字符)
   wchar_t wts[]=L"杂酱面";
    wprintf(L"%s\n",wts); //输出 wts (字符串)
    system("pause");
}

你可能感兴趣的:(个人方案)