Exploring Java’s UTF Support

 

Java supports UTF in four main ways.
  1. DataOutputStream.writeUTF / DataInputStream/ readUTF: modified UTF-8.
  2. OutputStreamWriter/InputStreamReader: any encoding including UTF-8, UTF-16, UTF-16BE, UTF-16LE.
  3. String.getBytes / new String: any encoding including UTF-8, UTF-16, UTF-16BE, UTF-16LE.
  4. CharBuffer & CharsetEncoder. encoder/ ByteBuffer & CharsetDecoder. decode : any encoding including UTF-8, UTF-16, UTF-16BE, UTF-16LE.
I wrote this program to discover if Java conformed with the UTF standards. It demonstrates these four ways or writing and reading UTF. It turns out Java conforms, with the exception of writeUTF.
 
More information can refer http://mindprod.com/jgloss/utf.html

你可能感兴趣的:(utf-8,utf,utf-16,休闲,support,utf-32,Java’s)