为什么Utf8与ASCII兼容 [英] Why Utf8 is compatible with ascii

查看:684
本文介绍了为什么Utf8与ASCII兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AU+0041 LATIN CAPITAL LETTER A. ASCII中的A065.

A in UTF-8 is U+0041 LATIN CAPITAL LETTER A. A in ASCII is 065.

UTF-8如何与ASCII向后兼容?

How is UTF-8 is backwards-compatible with ASCII?

推荐答案

ASCII仅使用8位字节的前7位.因此,从0000000001111111的所有组合.此范围内的所有128个字节都映射到一个特定字符.

ASCII uses only the first 7 bits of an 8 bit byte. So all combinations from 00000000 to 01111111. All 128 bytes in this range are mapped to a specific character.

UTF-8保留这些确切的映射.在ASCII中用01101011表示的字符在UTF-8中也用相同的字节表示.所有其他字符均按多个字节的顺序进行编码,其中每个字节的最高位均设置为1.也就是说,UTF-8中所有非ASCII字符的每个字节的格式均为1xxxxxxx.

UTF-8 keep these exact mappings. The character represented by 01101011 in ASCII is also represented by the same byte in UTF-8. All other characters are encoded in sequences of multiple bytes in which each byte has the highest bit set; i.e. every byte of all non-ASCII characters in UTF-8 is of the form 1xxxxxxx.

这篇关于为什么Utf8与ASCII兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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