计算机究竟是如何将 ASCII 转换为二进制的?

发布于 2025-01-17 15:48:58 字数 104 浏览 3 评论 0原文

我已经读到,当您按键盘上的键时,操作系统会将其转换为相应的ASCII,然后计算机将ACII转换为二进制。但是,计算机的哪一部分将ASCII转换为二进制?这个问题可能很愚蠢,因为我才开始学习CS。

I have read that when you press a key on the keyboard, the OS will translate it to the corresponding ASCII, then the computer will convert ACII to Binary. But, what part of the computer converts ASCII to Binary? The question may be stupid because I have only started to learn CS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听,心雨的声音 2025-01-24 15:48:58

忍受我,自从我处理这种事情以来已经有一段时间了...
当您按键盘上的键时,会升高(非常低的)电压信号,并由主板上的一个I/O子系统之一检测到 - 在这种情况下,负责连接键盘连接的端口的信号。到(例如USB,DIN,蓝牙等)。

然后,I/O处理程序向中断处理程序发出信号,该处理程序又将其作为键盘中断发送到操作系统的键盘驱动程序。键盘驱动程序根据硬件的特定规则将此高优先级中断的信号映射到二进制值。而且,按键的二进制表示形式是操作系统使用和/或将其转移到另一个程序的值(例如文字处理器,控制台/终端,电子邮件等)。

例如,假设一个非常简单的单字节ASCII系统(如今它变得更加复杂-UTF-8,UTF-16,EBCDIC等):

当您按Lettersg 和h,分别分别将两个电压转换为二进制值0110011101001000。但是由于计算机不了解“字母”的概念,因此这些二进制值代表数字(计算机没有问题)。在十进制中,这将是10372

那么实际字母进来的地方呢? ASCII代码是二进制表示,其数字值(在DEC,十六进制,OCT等)和相应的符号之间的映射。在这种情况下,符号为 g h ,然后在屏幕上“绘画”。字母,数字,标点符号 - 它们都是数字的图形表示 - 如果您愿意的话,很少的图像。

Bear with me, it has been a while since I dealt with this sort of thing...
When you press a key on the keyboard, a (very low) voltage signal is raised and is detected by one of the I/O subsystems on the motherboard - in this case the one responsible for the signals at the port that the keyboard is connected to (e.g. USB, DIN, Bluetooth, etc).

The I/O handler then signals this to the interrupt handler, which in turn sends it as a keyboard interrupt to the operating system's keyboard driver. The keyboard driver maps this high-priority interrupt signal to a binary value according to the hardware's specific rules. And this binary representation of the pressed key is the value that the operating system uses and/or hands over to another program (like a word processor, console/terminal, email, etc).

For example, and assuming a very simple, single-byte ASCII-based system (it gets a lot more complicated these days - UTF-8, UTF-16, EBCDIC, etc., etc.):

When you press the letters g and H, the two voltages get translated into binary values 01100111 and 01001000 respectively. But since the computer does not understand the concept of "letters", these binary values represent numbers instead (no problem for the computer). In decimal this would be 103 and 72 respectively.

So where do the actual letters come in? The ASCII code is a mapping between the binary representation, its numeric value (in dec, Hex, Oct, etc.) and a corresponding symbol. The symbols in this case being g and H, which the computer then "paints" on the screen. Letters, numbers, punctuation marks - they are all graphical representations of a number -- little images if you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文