Invisible characters in Java Strings

前端 未结 2 817
灰色年华
灰色年华 2020-12-20 14:06
String a = \"Hello\\u200e\";
String b = \"Hello\\u200f\";

System.out.println(\"a = \'\" + a + \"\' and b = \'\" + b + \"\' are length \"
                     + a.le         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-20 14:34

    U+200E and U+200F are not printable characters. They're both control characters which dictate how the text should be rendered - either left to right, or right to left.

    You won't see these in the terminal, and they shouldn't be equivalent strings.

    0x200E ^ 0x200F != 0

提交回复
热议问题