【发布时间】:2012-11-08 14:51:30
【问题描述】:
参考ISO 8859-1标准,知道£这个字符的值是0xa3,我想用c来显示,所以我写了这个程序:
#include <stdio.h>
int main()
{
printf( "\\xa3 is: %c.\n", '\xa3' );
printf( "£ is: %c.\n", '£' );
return 0;
}
我将此源代码文件保存为 iso 8859-1 编码。我希望我的程序在printf 遇到每个%c 时显示两次£。
但是,它不起作用,为什么?如何修改我的程序以实现我的目标。
我正在使用 linux。
编辑:
它的显示是这样的:
\xa3 is: �.
£ is: �.
【问题讨论】:
-
您的终端设置为 ISO-8859-1 了吗?
-
'但是,它不起作用' - 会发生什么?怎么不行?
-
@deanWombourne,问题已更新。
标签: c encoding iso-8859-1