2005년 8월 1일 월요일

UTF-16으로 getBytes() 할 때..

String을 특정 인코딩을 사용하여 Byte 배열을 얻을 때 사용하는 메소드가 getBytes() 입니다. 그 중에서 "UTF-16"으로 인코딩하기를 원하는 경우 3가지의 인자를 줄 수 있습니다. 각각은 "UTF-16", "UTF-16BE", "UTF-16LE" 입니다. 각각의 차이는 다음과 같습니다.

  • UTF-16(UTF-16) :
    Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark
  • UTF-16BE(UnicodeBigUnmarked) :
    Sixteen-bit Unicode Transformation Format, big-endian byte order
  • UTF-16LE(UnicodeLittleUnmarked) :
    Sixteen-bit Unicode Transformation Format, little-endian byte order

  • byte-order mark는 Windows같이 Little endian을 사용하는 경우는 byte-order로 fffe가 붙고, Mac OS같이 big endian을 사용하는 경우는 byte-order가 feff가 붙습니다.

    댓글 2개: