UTF8 ANSI Unicode/UCS2 UCS4 所占存储比较_高山流水_百度空间

UTF8 ANSI Unicode/UCS2 UCS4 所占存储比较_高山流水_百度空间

UTF8 ANSI Unicode/UCS2 UCS4 所占存储比较

UTF8是一种储存和传送的格式,如前所述,每个Unicode/UCS字符都以 2或4个bytes来储存,看看以下的比较:

以"I am Chinese"为例
用ANSI储存:12 Bytes
用Unicode/UCS2储存:24 Bytes + 2 Bytes(header)
用UCS4储存:48 Bytes + 4 Bytes(header)

以"我是中国人"为例
用ANSI储存:10 Bytes
用Unicode/UCS2储存:10 Bytes + 2 Bytes(header)
用UCS4储存:20 Bytes + 4 Bytes(header)

由此可见直接以Unicode/UCS的原始形式来储存是一种极大的浪费,而且也不利于互联网的传输(中文稍为合算一点^_^)。

有见及此,Unicode/UCS的压缩形式--UTF8出现了,套用官方网站的首句话『UTF-8 stands for Unicode Transformation Format-8. It is an octet (8-bit) lossless encoding of Unicode characters.』,由于UTF也适用于编码UCS,故亦可称为『UCS transformation formats (UTF)』

UTF8是以8bits即1Bytes为编码的最基本单位,当然也可以有基于16bits和32bits的形式,分别称为UTF16和UTF32,但目前用得不多,而UTF8则被广泛应用在文件储存和网络传输中。
原文地址:https://www.cnblogs.com/lexus/p/2826708.html