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

后端 未结 4 1132
春和景丽
春和景丽 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:35

    It's 0xF0 in EBCDIC. I've never used an EBCDIC compiler, but I'm told that they were all the rage at IBM for a while.

    There's no requirement in the C++ standard that the source or execution encodings are ASCII-based. It is guaranteed that '0' == '1' - 1 (and in general that the digits are contiguous and in order). It is not guaranteed that the letters are contiguous, and indeed in EBCDIC 'J' != 'I' + 1 and 'S' != 'R' + 1.

提交回复
热议问题