Nikos K
Nikos K

Reputation: 41

android string equals returns false but they are equal

I've written this code:

Log.d("DE", p1.pId);

and I know p1.pId is "123" (it's String and all)

I then do:

if (p1.pId.equals("123"))

and it's always false.

Eclipse debugging tooltip is EXACTLY THE SAME.

I've noticed that via Log.d though I don't see 123 but 123 with 1 slashed somehow (like a special character). I've tried copy pasting in Notepad++ only to get ??123, when I paste in notepad I get smaller text.

Instead of 123 I get (maybe) ff fe ff fe ff fe 31 in hex.

Please check this picture: http://img821.imageshack.us/img821/8616/foox.png

Upvotes: 1

Views: 654

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234795

Your string has Unicode byte order marks at the beginning. They need to be stripped off. If you show the code where is p1.pId coming from, perhaps we can explain how it can be fixed there.

Upvotes: 1

Related Questions