Please tell me how the first use of start_with returned false.
Thanks!
Please tell me how the first use of start_with returned false.
Thanks!
Your string may contain a hidden unicode character.
If so, the string starts with that character, not with #
, which is why you're getting false
.
To see it in Ruby, take the string you're running start_with?
on and instead run .unpack('C*')
. This will return an array of numbers between 0
and 255
, representing the integer values of every byte in the string. Normal printable ASCII characters only go up to 126
. Any number higher than that will be a clue that there is a non-printing character hiding in your string.
UPDATE
In this particular case, it turned out that using this diagnostic method showed that there were indeed extra bytes at the beginning of the string. They appeared at the beginning of the array as [239, 187, 191, ...]
, the string equivalent of which is "\xEF\xBB\xBF"
or the UTF-8 codepoint ZERO WIDTH NO-BREAK SPACE, which is inserted as a byte-order mark at the beginning of a file by some text editors.