Unequal Bs

HKT HKT
Views

Who can tell me what is the result of this expression?

"В" == "B"

You can use a repl of your choice, say Scala or Python, to evaluate the expression. Be prepared with an explanation for the result you see 😉

 

 

Explanation

You should have been surprised to see “В” == “B” return false. I too was, and lost more than a day why code was not working.

The second “B” is, as you see, the second letter in the English alphabet. The first “В” is not so. It is the Cyrillic letter pronounced Ve.

You can test it by copying the letter (to the clipboard), and running using the following command:

xpaste | xxd # pbpaste on macOS

That is a great phishing instrument! I am still puzzled how the Cyrillic Ve ended up in my code. I can’t remember copy pasting from a web page or something man 🤷‍♂️. In any case, you can’t always believe what you see.

quiz