A colleague told me:
C++ is not ASCII-aware.
The source character set of a C++ program is implementation-defined, so to what extent is my colleague incorrect?
A colleague told me:
C++ is not ASCII-aware.
The source character set of a C++ program is implementation-defined, so to what extent is my colleague incorrect?
The c++ compiler needs to be ASCII aware when it links the numeric 48
value to '0'
. So yes, it needs to be ASCII-aware.
But does it always needs to? Imagine you work with EBCDIC ('0' => 240
). Then the compiler probably doesn't care about ASCII. Maybe that's what you colleague meant.
C++, generally speaking, does not really care about ASCII. It is an implementation detail.
The C++ standard text is "aware" of ASCII in that it makes non-normative mention in a footnote:
[C++11: Footnote 14]:
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 doing so, it is declaring that the standardised language itself is not ASCII-aware.
"Seems like awareness of ASCII to me!" you might say. Well, no. The mere mention of "ASCII" in the language definition has not made the language ASCII-aware. This is in the same way that you can program a robot to say the words "I am not self-aware" without requiring that the robot become aware of self.