【发布时间】:2010-11-08 01:30:33
【问题描述】:
这是一个 ANSI C 问题。我有以下代码。
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
int main()
{
if (!setlocale(LC_CTYPE, "")) {
printf( "Can't set the specified locale! "
"Check LANG, LC_CTYPE, LC_ALL.\n");
return -1;
}
wint_t c;
while((c=getwc(stdin))!=WEOF)
{
printf("%lc",c);
}
return 0;
}
我需要完整的 UTF-8 支持,但即使在这个最简单的级别上,我能以某种方式改进它吗?为什么使用wint_t,而不是wchar,并进行适当的更改?
【问题讨论】: