在哪里可以找到每个C99字符集的所有字符的表格?

Dav*_*her 9 c c99 character-encoding

我正在为以下每个C字符集中的每个字符寻找一个表(或生成一个表的方法):

  • 基本字符集
  • 基本执行字符集
  • 基本源字符集
  • 执行字符集
  • 扩展字符集
  • 源字符集

C99在5.2.1节中提到了所有这六个.但是,我发现阅读非常神秘,缺乏细节.

它明确定义的唯一字符集是基本执行字符集基本源字符集:

拉丁字母表中的52个大写和小写字母:

ABCDEFGHIJKLMNOPQRSTU VWXYZ

abcdefghijklmnopqrstu vwxyz

十位小数:

0 1 2 3 4 5 6 7 8 9

29个图形字符:

!"#%&'()*+, - ./ :; <=>?[\ _] ^ _ {|}〜

4个空格字符:

空格,水平标签,垂直标签,换页

我相信这些与基本字符集相同,但我猜是因为C99没有明确说明这一点.其余的字符集对我来说有点神秘.

谢谢你尽你所能的帮助!:)

Ada*_*eld 5

除了您提到的基本字符集之外,所有其他字符集都是实现定义的.这意味着它们可以是任何东西,但实现(即C编译器/库/工具链实现)必须记录这些决策.这里的关键段落是:

§3.4.1 实现定义的行为
未指定的行为,其中每个实现都记录了如何做出选择

§3.4.2 特定语言环境的行为
行为,取决于每个实现文档的国籍,文化和语言的本地约定

§5.2.1.1 字符集
应定义两组字符及其关联的整理顺序:写入源文件的集合(源字符集),以及在执行环境中解释的集合(执行字符集).每个集合进一步划分为基本字符集,其内容由本子条款给出,以及一组零个或多个特定于语言环境的成员(不是基本字符集的成员),称为扩展字符.组合集也称为扩展字符集.执行字符集的成员值是实现定义的.

因此,查看C编译器的文档以了解其他字符集是什么.例如,在我的gcc手册页中,一些命令行选项说明:

   -fexec-charset=charset
       Set the execution character set, used for string and character
       constants.  The default is UTF-8.  charset can be any encoding
       supported by the system's "iconv" library routine.

   -fwide-exec-charset=charset
       Set the wide execution character set, used for wide string and
       character constants.  The default is UTF-32 or UTF-16, whichever
       corresponds to the width of "wchar_t".  As with -fexec-charset,
       charset can be any encoding supported by the system's "iconv"
       library routine; however, you will have problems with encodings
       that do not fit exactly in "wchar_t".

   -finput-charset=charset
       Set the input character set, used for translation from the
       character set of the input file to the source character set used by
       GCC.  If the locale does not specify, or GCC cannot get this
       information from the locale, the default is UTF-8.  This can be
       overridden by either the locale or this command line option.
       Currently the command line option takes precedence if there's a
       conflict.  charset can be any encoding supported by the system's
       "iconv" library routine.

要获取支持的编码列表iconv,请运行iconv -l.我的系统有143种不同的编码可供选择.