Javascript string comparison fails when comparing unicode characters

后端 未结 4 1314
温柔的废话
温柔的废话 2020-11-30 08:18

I want to compare two strings in JavaScript that are the same, and yet the equality operator == returns false. One string contains a special character (eg. the

4条回答
  •  既然无缘
    2020-11-30 08:41

    UTF-8 is a complex thing. The charset has two different codes for characters such as á, é etc. As you already see in the URL encoded version, the HEX bytes of which the character is made differ for both versions.

    See this answer for more information.

提交回复
热议问题