码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA中的编码分析

时间:2017-04-23 01:15:48      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:mos   sign   flow   fit   tac   关注   was   its   and   

在实际编程中可以不用关注JVM中使用的是什么编码,而只需要关注自己输出需要采用的编码,JVM会根据你设置的编码正确操作。

1、String采用的是什么编码?

  很多厂家根据规范实现了JVM,JVM只说明了String应该符合Unicode编码。Unicode编码只是一种编码模型,utf8,utf16,utf32都属于Unicode模型

      ,具体的信息参阅http://www.cnblogs.com/YDDMAX/p/5360709.html

2、为什么JAVA中Char是两个字节?

     参阅http://stackoverflow.com/questions/3956734/why-does-the-java-char-primitive-take-up-2-bytes-of-memory

     When Java was originally designed, it was anticipated that any Unicode character would fit in 2 bytes (16 bits), so char and Character were designed accordingly. In fact, a Unicode        character can now require up to 4 bytes. Thus, UTF-16, the internal Java encoding, requires supplementary characters use 2 code units. Characters in the Basic Multilingual Plane        (the most common ones) still use 1. A Java char is used for each code unit. This Sun article explains it well.

 

JAVA中的编码分析

标签:mos   sign   flow   fit   tac   关注   was   its   and   

原文地址:http://www.cnblogs.com/YDDMAX/p/6750322.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!