C standard : Character set and string encoding specification

帅比萌擦擦* 提交于 2019-11-30 17:51:43

C is not greedy about character sets. There's no such thing as "default character set", it's implementation defined - although it's mostly ASCII or UTF-8 on most modern systems.

The standard doesn't specify a default encoding because existing practice already had C implemented on machines with lots of different encodings, for example Honeywell mainframes and IBM mainframes.

I would expect gcc to take its default from the locale currently specified by LC_CHARSET, but I've never tested it.

VC++ takes its default from a Control Panel setting. That default Control Panel setting varies according to which country Windows was purchased in, and most users never change it, but they can change it while installing Windows can change it later.

Trigraphs were invented so that a source program could be copied from an environment with one locale to an environment with a slightly different locale and still be compiled. For example if a Windows user in China uses trigraphs then a Windows user in Greece would be able to compile the same source program. However, if the locales differ too much, for example one using EBCDIC and one using EUC, trigraphs won't suffice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!