Is there any reason why a string wouldn't equal itself? I am processing a large amount of strings and some strings are, in the end, not equaling themselves.
Here is an image that shows what I am talking about.
Any ideas?
RESOLVED: There is a carriage return (\r) attached to the end of one of the strings. I used String.length to see the lengths of each string, and they differed (5 and 6). I then looked through the string using String.charAt. In Chrome, this showed an empty string (""). However, the empty string was not a falsy value. I tried this in FireFox and it showed the carriage return.
In any language if one string contains some unreadable characters, and the other doesn't they will be different even if they seem to be equal by human.
Try print their lengths and print them char-to-char
It could be that one of the characters is a UTF-8 representation of the ascii equivalent.
Here is a transliteration jquery plugin: http://code.google.com/p/jquery-transliteration-plugin/wiki/Usage
There could also be a control sequence at the end, like a BOM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With