开发者

ASCII character problem on mac. Can't print the black square(which is char(219))

开发者 https://www.devze.com 2023-02-15 18:23 出处:网络
When I\'m trying to do this code in C++ cout << char(219); the output on my mac is question mark?

When I'm trying to do this code in C++

cout << char(219);

the output on my mac is question mark ? However, on PC it gives me a black square. Does anyone have any idea why on mac there is only 128 characters, when it should be 256? Thanks 开发者_运维知识库for your help.


There's no such thing as ASCII character 219. ASCII only goes up to 127. chars 128-255 are defined in different ways in different character encodings for different languages and different OSs.

  • MacRoman defines it as .
  • IBM code page 437 (used at the Windows command prompt) defines it as .
  • Windows code page 1252 (used in Windows GUI programs) defines it as Û.
  • UTF-8 defines it as a part of a 2-byte character. (Specifically, the lead byte of the characters U+06C0 to U+06FF.)


ASCII is really a 7-bit encoding. If you are printing char(219) that is using some other encoding: on Windows most probably CP 1252. On Mac, I have no idea...


When a character is missing from an encoding set, it shows a box on Windows (it's not character 219, which doesn't exist) Macs show the question mark in a diamond symbol because a designer wanted it that way. But they both mean the same thing, missing/invalid character.

0

精彩评论

暂无评论...
验证码 换一张
取 消