Question: I understood that Java always uses Big Endian. Why does the code at How can I store and retrieve Unicode or Double Byte data in a file using the java.io libraries? produce Little Endian output?
Answer:
Actually, Java's guaranteed usage of Big Endian only applies to what I will loosely call "numbers." String or byte encodings for characters are a different matter altogether. The Little Endian output in the referenced code results from Java's interpretation of the "Unicode" alias, which on NT, at least, apparently resolves to "UnicodeLittle." This is not a problem in the code, because a byte order mark is written, but it would have been better to use an encoding from character encoding or Supported Encodings.
本文解释了Java中Unicode编码为何有时会以Little Endian形式出现,尽管Java通常使用Big Endian。文章指出,对于字符编码,Java的行为可能有所不同,并讨论了如何正确处理这种情况。
1953

被折叠的 条评论
为什么被折叠?



