Java 8 UTF-8 encoding issue (java bug?)

后端 未结 3 1934
猫巷女王i
猫巷女王i 2020-11-29 08:15

There is an inconsistency when creating a String with UTF-8 encoding.

Run this code:

public static void encodingIssue() throws IOException {
    byte         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 09:06

    That is a surrogate, right? I'm not a Unicode expert, but I don't think it has meaning by itself. Java 8 changed to support Unicode 6.2. Maybe it's stricter about this. 65533 is the standard 0xFFFD replacement character, which means, "not representable". Is there a real case where you need to interpret this as a string? because it seems like Unicode is saying that doesn't make sense as a character anymore.

提交回复
热议问题