JAVA中的編碼分析

來源:互聯網
上載者:User

標籤: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中的編碼分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.