Is the character set of a char literal guaranteed to be ASCII?

后端 未结 4 1134
春和景丽
春和景丽 2020-12-07 01:47

Coming from a discussion started here, does the standard specify values for characters? So, is \'0\' guaranteed to be 48? That\'s what ASCII would tell us, but

4条回答
  •  情书的邮戳
    2020-12-07 02:25

    According to the C++11 stardard N3225

    The glyphs for the members of the basic source character set are intended to identify characters from the subset of ISO/IEC 10646 which corresponds to the ASCII character set. However, because the mapping from source file characters to the source character set (described in translation phase 1) is specified as implementation-defined, an implementation is required to document how the basic source characters are represented in source files

    In short, the character set is not required to be mapped to the ASCII table, even though I've never heard about any different implementation

提交回复
热议问题