C语言与中文

 1 int main(void)
2 {
3 char *s = setlocale(LC_ALL,"zh_CN.utf8");
4 // printf("%s \n",s);
5 if (NULL == s)
6 {
7
8 printf("Your system does not support Chinese.\n");
9
10 } else {
11
12 wchar_t wa[] = L"中国北京";
13 wchar_t *wpi;
14 wchar_t wc = L'';
15
16 wpi = wcschr( wa, wc );
17 printf( "在 %ls 中找到了字符 '%lc' \n",wa,*wpi );
18
19 }
20
21 return 0;
22 }


输出

在 中国北京 中找到了字符 '北'

  • ubuntu系统默认语言英文,安装了中文包

posted on 2011-11-24 16:02  I'm legend  阅读(366)  评论(0编辑  收藏  举报