JAVA中的编码分析

在实际编程中可以不用关注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.

 

转载于:https://www.cnblogs.com/YDDMAX/p/6750322.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值