免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: chenzhihui
打印 上一主题 下一主题

[函数] 有谁知道ascii值转化成ascii字符,用的那个函数。。。新手拜托 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-01-13 15:42 |只看该作者
原帖由 mitsuki 于 2007-1-13 15:19 发表


ASCII码表

原帖由 mitsuki 于 2007-1-13 15:21 发表
不过如果输出数字的话要重新考虑


谢谢。我找了一些信息,链接如下,并未发现您所说的 “ASCII值是HEX值”。

http://en.wikipedia.org/wiki/ASCII
http://www.itscj.ipsj.or.jp/ISO-IR/001.pdf
http://www.unicode.org/charts/PDF/U0000.pdf
http://www.wps.com/projects/codes/index.html
http://boujemong.blogspot.com/2007/01/blog-post_03.html
mitsuki 该用户已被删除
12 [报告]
发表于 2007-01-13 16:29 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
13 [报告]
发表于 2007-01-13 16:40 |只看该作者
原帖由 mitsuki 于 2007-1-13 16:29 发表
对不起,您给的链接我都打不开
我说的确实不准确,应该是BCD码
我考虑用%d得出的值不换算的话在ASCII表上查不到,所以加了这么一句希望回答能够准确些,没想到还是错了
不过我仍然认为ASCII码的值应该用HEX值,方便查表


谢谢。

From Wikipedia, the free encyclopedia:

In computing and electronic systems, Binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. Its main virtue is that it allows easier conversion to decimal digits for printing or display. Its drawbacks are the complexity of circuits needed to implement mathematical functions and the space wasted in the encoding - 6 wasted patterns per digit. Even though the importance of BCD has diminished, it is still encountered.

In BCD, a digit is usually represented by four bits which, in general, represent the values/digits/characters 0-9. Other combinations are sometimes used for sign or other indications.

To BCD-encode a decimal number using the common encoding, each digit is encoded using the four-bit binary bit pattern for each digit. For example, the number 127 would be:

0001 0010 0111

Since most computers store data in eight-bit bytes, there are two common ways of storing four-bit BCD digits in those bytes:

    * each digit is stored in one byte, and the other four bits are then set to all zeros, all ones (as in the EBCDIC code), or to 0011 (as in the ASCII code)
    * two digits are stored in each byte.

Unlike pure binary encodings large numbers can easily be displayed by splitting up the nibbles and sending each to a different character with the logic for each display being a simple mapping function. Converting from pure binary to decimal for display is much harder involving integer multiplication or divide operations. The BIOS in many PCs keeps the date and time in BCD format, probably for historical reasons (it avoided the need for binary to ASCII conversion).

附 PDF 格式文档(和 ASCII 等字符编码有关的历史):

----

[ 本帖最后由 langue 于 2007-1-13 16:41 编辑 ]

WPS - Annotated history of character codes.pdf

366.51 KB, 下载次数: 24

论坛徽章:
0
14 [报告]
发表于 2007-01-13 16:48 |只看该作者
看到楼上的帖子……
我又问了自己一句,CU的这些版主到底都是干什么的……
mitsuki 该用户已被删除
15 [报告]
发表于 2007-01-13 17:00 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
16 [报告]
发表于 2007-01-13 17:20 |只看该作者
原帖由 mitsuki 于 2007-1-13 17:00 发表
...我不知道楼上想表达什么意思,当然我也不知道版主大人想表达个什么意思
“Even though the importance of BCD has diminished, it is still encountered.”
“The BIOS in many PCs keeps the date and time in BCD format, probably for historical reasons (it avoided the need for binary to ASCII conversion).”
但是我明白这两句话想表达个什么意思,无论如何,ASCII使用BCD码,所以它应该是HEX值
我想我所说的“ASCII码应该是HEX值”在这里已经表达的很清楚


惭愧。我只是个实习的

我说不过您。ASCII 是 ASCII,BCD 是 BCD。

BCD 8 4 2 1 编码:

0    -    0000
1    -    0001
2    -    0010
3    -    0011
4    -    0100
5    -    0101
6    -    0110
7    -    0111
8    -    1000
9    -    1001

BCD 2 4 2 1 编码:

0    -    0000
1    -    0001
2    -    0010
3    -    0011
4    -    0100
5    -    1011
6    -    1100
7    -    1101
8    -    1110
9    -    1111

我想表达的意思实际是,ASCII 编码的编码结果,用几进值来表现都无所谓。至于您查询的表用了十六进制(是您所描述的 “HEX” 吗?),我想,可能是因为那张表适合黑客们使用吧。至少我不是黑客,这个对我就无所谓了。

另外,似乎最初的 ASCII 码表和十六进制没什么关系。

[ 本帖最后由 langue 于 2007-1-13 17:21 编辑 ]
mitsuki 该用户已被删除
17 [报告]
发表于 2007-01-13 17:20 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
18 [报告]
发表于 2007-01-13 17:24 |只看该作者
原帖由 mitsuki 于 2007-1-13 17:20 发表
......再简单的问题,也一定要弄懂......
《微型计算机原理系统原理及应用》周明德 清华大学出版社
507页,附录
字符'A',MSD=0100,LSD=0001
它的ASCII码MSD LSD:0100 0001,如果用16进制的二进制码表示,就是41
也就是MSD=0100=4,LSD=0001
这个换算的另一个说法是:
A的ASCII码0100 0001的BCD码表示是41


多谢指教。那么,是否 '1' 这个字符,也可以,或者必须用同样的逻辑来分解/解释?
mitsuki 该用户已被删除
19 [报告]
发表于 2007-01-13 17:25 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
mitsuki 该用户已被删除
20 [报告]
发表于 2007-01-13 17:36 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP