请解释: 7bit编码和8bit编码?

chrislois 2003-12-18 11:51:28
请解释: 7bit编码和8bit编码?哪里有二者的转换函数(c语言)?谢谢!
...全文
2242 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
shinedreamnt 2003-12-22
  • 打赏
  • 举报
回复
这是规范上面关于编码的例子.最权威.

6.1.2.1.1 Packing of 7-bit characters
If a character number a is noted in the following way:
b7 b6 b5 b4 b3 b2 b1
aa ab ac ad ae af ag
The packing of the 7-bits characters in octets is done by completing the octets with zeros on the left.
For examples, packing: a
- one character in one octet:
bits number:
7 6 5 4 3 2 1 0
0 1a 1b 1c 1d 1e 1f 1g
- two characters in two octets:
bits number:
7 6 5 4 3 2 1 0
2g 1a 1b 1c 1d 1e 1f 1g
0 0 2a 2b 2c 2d 2e 2f
- three characters in three octets:
bits number:
7 6 5 4 3 2 1 0
2g 1a 1b 1c 1d 1e 1f 1g
3f 3g 2a 2b 2c 2d 2e 2f
0 0 0 3a 3b 3c 3d 3e

- seven characters in seven octets:
bits number:
7 6 5 4 3 2 1 0
2g 1a 1b 1c 1d 1e 1f 1g
3f 3g 2a 2b 2c 2d 2e 2f
4e 4f 4g 3a 3b 3c 3d 3e
5d 5e 5f 5g 4a 4b 4c 4d
6c 6d 6e 6f 6g 5a 5b 5c
7b 7c 7d 7e 7f 7g 6a 6b
0 0 0 0 0 0 0 7a
- eight characters in seven octets:
bits number:
7 6 5 4 3 2 1 0
2g 1a 1b 1c 1d 1e 1f 1g
3f 3g 2a 2b 2c 2d 2e 2f
4e 4f 4g 3a 3b 3c 3d 3e
5d 5e 5f 5g 4a 4b 4c 4d
6c 6d 6e 6f 6g 5a 5b 5c
7b 7c 7d 7e 7f 7g 6a 6b
8a 8b 8c 8d 8e 8f 8g 7a
The bit number zero is always transmitted first.
Therefore, in 140 octets, it is possible to pack (140x8)/7=160 characters.
shinedreamnt 2003-12-22
  • 打赏
  • 举报
回复
GSM规范里面定义了短信的编码格式有三种.最大140个字节.
1)GSM7bit(8bit编码),每个字符占1个字节,最高位为0,共可以发送140个字符,
2)UNICODE,每个字符占2个字节,如中文,共可以发送70个字符,
3)GSM7bit压缩版(7bit编码),每个字符占7个bit,7个字节中可以放8个字符,共可以发送160个字符.

详细的可以见GSM03.38在www.3gpp.org可以下载.

Letbeger 2003-12-22
  • 打赏
  • 举报
回复
关注
chrislois 2003-12-22
  • 打赏
  • 举报
回复
NowCan(能量、激情、雨水、彩虹——雷雨云) :

帮忙给出"This is testing !"在短信里的的7bit编码,8bit编码结果?
chrislois 2003-12-22
  • 打赏
  • 举报
回复
hifrog(seafrog)
是把"This is testing !"紧凑得按位方在8位字长中吗?再把8位字长中的二进制的值或ascii码显示出来?


差不多这个意思。帮忙给出"This is testing !"的7bit编码,8bit编码结果?
zhangake 2003-12-21
  • 打赏
  • 举报
回复
ding.........
NowCan 2003-12-20
  • 打赏
  • 举报
回复
用在什么地方的?如果是短信里的,7位编码是压缩的,不能简单的去掉最高位。
AlexXin 2003-12-20
  • 打赏
  • 举报
回复
关注
chrislois 2003-12-20
  • 打赏
  • 举报
回复
hifrog(seafrog):
因为有些应用规范中要求7bit编码,有些应用规范中要求8bit编码。
帮帮忙给出"This is testing !"的编码结果。
hifrog 2003-12-20
  • 打赏
  • 举报
回复
本来是8位编码的ascii字符集干吗变成7位的?
不过7位编码后字符串的值还是不变的,因为"This is testing !"中每个字符的ascii码都小于128。但是还是要放在8位的地址空间,如果紧凑得放安装ascii码的标准肯定是乱码了。
如果为了验证它们7位编码后的合法性,我们需要制定另一种编码标准了:(
hifrog 2003-12-20
  • 打赏
  • 举报
回复
是把"This is testing !"紧凑得按位方在8位字长中吗?再把8位字长中的二进制的值或ascii码显示出来?
hifrog 2003-12-18
  • 打赏
  • 举报
回复
7位到8位:
先用右移“>>”再用0x7F相“与”(&&)就可以。
8位到7位的话高位就要舍掉了。
chillman 2003-12-18
  • 打赏
  • 举报
回复
8bit编码的低段 就是 7bit的编码。不用转换!7bit的最高位补0就行了。
chrislois 2003-12-18
  • 打赏
  • 举报
回复
那请问:字符串"This is testing !"的7bit 8bit编码后分别为什么?谢谢!

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧