且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么printf(“%c”,1)返回笑脸而不是1的编码char

更新时间:2022-11-01 16:35:46

终端。例如,在我的OS X默认终端上,没有字符输出。

The output varies among different terminals. For example, on my OS X default terminal, no characters are output.

在您的情况下,输出大概是由于某些历史原因。简而言之,这是因为代码页437是将字符 0x01 映射到 U + 263A 的代码页, MS-DOS。

In your case, is output presumably due to some historical reasons. In short, this is because code page 437, which maps byte 0x01 to U+263A, is the character set of MS-DOS.