上古卷轴5盗贼会长套装:请问utf8的意思?

来源:百度文库 编辑:高校问答 时间:2024/04/29 07:09:02

网页字符的一种,跟汉语代码GB2312差不多
UTF8 == Unicode Transformation Format -- 8 bit
是Unicode传送格式。即把Unicode文件转换成BYTE的传送流。

UTF8流的转换程序:
Input: unsigned integer c - the code point of the character to be encoded (输入一个unicode值)
Output: byte b1, b2,b3, b4 - the encoded sequence of bytes (输出四个BYTE值)
Algorithm(算法):
if (c<0x80)
b1 = c>>0 & 0x7F | 0x00
b2 = null
b3 = null
b4 = null
else if (c<0x0800)
b1 = c>>6 & 0x1F | 0xC0
b2 = c>>0 & 0x3F | 0x80
b3 = null
b4 = null
else if (c<0x010000)
b1 = c>>12 & 0x0F | 0xE0
b2 = c>>6 & 0x3F | 0x80
b3 = c>>0 & 0x3F | 0x80
b4 = null
else if (c<0x110000)
b1 = c>>18 & 0x07 | 0xF0
b2 = c>>12 & 0x3F | 0x80
b3 = c>>6 & 0x3F | 0x80
b4 = c>>0 & 0x3F | 0x80
end if
=====================
unicode 是一种编码表格,例如,给一个汉字规定一个代码。类似 GB2312-1980, GB18030等,只不过字集不同。
=====================
一个unicode码可能转成长度为一个BYTE,或两个,三个,四个BYTE的UTF8码,取决于unicode码的值。英文unicode码因为值小于0x80,只要用一个BYTE的UTF8传送,比送unicode两个BYTEs快。
UTF8是为传送unicode而想出来的“再编码”方法罢了。
UTF8转unicode用我上面给的程序反算即可。