Reputation: 39
"A character literal can be implicitly converted to its integer value in the character set of the machine on which the C++ program is on" ---from Bjarne Stroustrup's "The C++ Programming Language" book. Fourth edition page 143
How can a physical machine have its own character encoding scheme? I thought its up to software to enforce a given encoding scheme, and then the physicality of the computer just sees it as raw bytes. Can someone explain what he means by "the character set of the machine"?
page 144 goes on to say "Using any numeric notation for characters makes program nonportable across machines with different character sets".
Upvotes: 1
Views: 54
Reputation: 241741
At some point, a "physical machine" like a keyboard needs to have a built-in correspondence between binary codes and human-readable characters. When I/O devices were more physical, this correspondence was more concrete but it certainly still exists. Other than that, the operating system will normally impose such a correspondence in order to allow inter-operability; whether you consider the OS to be a part of "the machine" is a semantic question without a clear answer but in terms of language standards like that of C++, the "execution environment" for a hosted implementation certain includes the keyboard, the display, the persistent storage, and the OS glue which ties them together.
Upvotes: 2