When visiting the blog park, I saw an article that compares two strings for equality, compares two strings, and uses one night.
string m1 = "fa?c5?04?6b?c1?0a?ca?2e?1e?a9?55?eb?e4?53?7d?c0";string m2 = "fac5046bc10aca2e1ea955ebe4537dc0";
are not equal. Because the M1 contains invisible characters (Zero-width Non-joiner (ZWNJ), Zero-width Space (ZWSP), both of them)
Workaround:
①. Copy to QQ, you can see the difference.
②. Using Java code to differentiate
1String m1 = "fa c5? 6b? C1 0a?" CA? 2e 1e? A9? eb? e4? 7d? c0;2String m2 = "fac5046bc10aca2e1ea955ebe4537dc0";3SYSTEM.OUT.PRINTLN ("M1 Length:" +m1.length () + "\ n" + "m2 Length:" +m2.length ());4 byte[] bs =m1.getbytes ();5System.out.print ("M1:");6 for(byteb:bs) {7System.out.print (b + ""));8 }9 System.out.println ();TenString all = M1.replaceall ("\\p{c}", ""); OneSystem.out.println (M2.equals (All));
Get the output result:
Length of M1:length of m2:M1:
-30-128-116-30-128-117 48 97-30-128-116-30-128-117 99 97-30-128-116-30-128-117 50 101-30-128-116-30- 128-117 49 101-30-128
-116-30-128-117 97 57-30-128-116-30-128-117 53 53-30-128-116-30-128-117 101 98-30-128-116-30-128-117 101 52-30-128-116-30
True
Java Invisible character processing