java io读书笔记(4)字符数据

Number只是java程序中需要读出和写入的一种数据类型。很多java程序需要处理有一大堆的字符组成的text,因为计算机真正懂得的只有数字,因此,字符按照某种编码规则,和数字对应。

比如:在ASCII编码中,字符A对应着数字65.字符B对应着数字66.

下面介绍集中编码模式:

1)ASCII

ASCII=American Standard Code for Information Interchange。7位字符集。

2)Latin-1

ISO 8859-1, Latin-1,8为字符集。

3)Unicode

UTF-32 is the most naïve encoding. It simply represents each character as a single 4-byte (32-bit) int.

UTF-16 represents most characters as a 2-byte, unsigned short. However, certain less common Chinese characters, musical and mathematical symbols, and characters from dead languages such as Linear B are represented in four bytes each. The Java virtual machine uses UTF-16 internally. In fact, a Java char is not really a Unicode character. Rather it is a UTF-16 code point, and sometimes two Java chars are required to make up one Unicode character.

Finally, UTF-8 is a relatively efficient encoding (especially when most of your text is ASCII) that uses one byte for each of the ASCII characters, two bytes for each character in many other alphabets, and three-to-four bytes for characters from Asian languages. Java's .class files use UTF-8 internally to store string literals.

4) 其他编码

5)Cha字符类型

上一篇:ubuntu环境下lnmp环境搭建(1)之Mysql


下一篇:传说是小米家的一道面试题难倒了某Java程序员。扑克牌排序问题。