Are ASCII characters always encoded the same way i

2019-05-26 15:47发布

问题:

In ASCII, the character < is encoded as a single-byte character 0x3C, what I'd like to know is that is there a character set where < is encoded differently? I tried UTF-8, it's the same. I tried GB2312 and it's the same...

Another question, are all ASCII characters the same in all character sets?

回答1:

The first 127 characters of ASCII are the same in all ASCII-derived character sets. They are not the same in non-ASCII-character sets (such as EBCDIC).

Characters with codes > 127 are different depending on the codepage and/or the encoding.



回答2:

No, there are some unofficial regional variants of ISO-646 which differ quite a lot from ASCII.



回答3:

In UTF-16 'abc' is encoded as '0 97 0 98 0 99', which is very similar to ASCII, but if you try to interpret it as ASCII, you will end up with an extra NUL character before (or after, depending on endianness) each character. Not a huge difference, but enough to make them uninterchangable.