ASCII码的排序背后有什么逻辑吗? [英] Is there any logic behind ASCII codes' ordering?

查看:23
本文介绍了ASCII码的排序背后有什么逻辑吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在教我学习工程学的弟弟 C.我在向他解释不同的数据类型是如何实际存储在内存中的.我向他解释了有符号/无符号数字和十进制浮点位背后的逻辑.在我告诉他 C 中的 char 类型的同时,我还带他了解了 ASCII 码系统以及 char 也是如何存储为 1 字节数的.

I was teaching C to my younger brother studying engineering. I was explaining him how different data-types are actually stored in the memory. I explained him the logistics behind having signed/unsigned numbers and floating point bit in decimal numbers. While I was telling him about char type in C, I also took him through the ASCII code system and also how char is also stored as 1 byte number.

他问我为什么A"被赋予了 ASCII 码 65 而没有其他任何东西?同样,为什么a"被​​指定为代码 97?为什么大写字母和小写字母的范围之间有6个ASCII码的差距?我对此一无所知.你能帮我理解一下吗,因为这也让我产生了极大的好奇心.到目前为止,我从未找到任何讨论过这个主题的书.

He asked me why 'A' has been given ASCII code 65 and not anything else? Similarly why 'a' is given the code 97 specifically? Why is there a gap of 6 ASCII codes between the range of capital letters and small letters? I had no idea of this. Can you help me understand this, since this has created a great curiosity to me as well. I've never found any book so far that has discussed this topic.

这背后的原因是什么?ASCII 代码是否有逻辑组织?

What is the reason behind this? Are ASCII codes logically organized?

推荐答案

有历史原因,主要是为了方便ASCII码转换:

There are historical reasons, mainly to make ASCII codes easy to convert:

数字(0x30 到 0x39)的二进制前缀为 110000:

Digits (0x30 to 0x39) have the binary prefix 110000:

0 is 110000
1 is 110001
2 is 110010

等等.所以如果你去掉前缀(前两个 '1's),你最终会得到二进制编码的十进制数字.

etc. So if you wipe out the prefix (the first two '1's), you end up with the digit in binary coded decimal.

大写字母有二进制前缀1000000:

Capital letters have the binary prefix 1000000:

A is 1000001
B is 1000010
C is 1000011

等等.同样的,如果你去掉前缀(第一个'1'),你最终会得到字母索引字符(A 是 1,Z 是 26,等等).

etc. Same thing, if you remove the prefix (the first '1'), you end up with alphabet-indexed characters (A is 1, Z is 26, etc).

小写字母有二进制前缀1100000:

Lowercase letters have the binary prefix 1100000:

a is 1100001
b is 1100010
c is 1100011

等等.和上面一样.因此,如果您将 32 (100000) 添加到大写字母,则您将得到小写版本.

etc. Same as above. So if you add 32 (100000) to a capital letter, you have the lowercase version.

这篇关于ASCII码的排序背后有什么逻辑吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆