About
This page shows you how to make the difference between two characters that are really visually similar.
Example
Problem
Are this two characters the same ?
–
-
Solution
To solve this problem, you need to pass them to an application or function to get their code point
Javascript Solution
The first solution is based on javascript but every language should give you a function to get the unicode code point
let codePoint = character.charCodeAt(0).toString(16)
- The first one is a dash cldr/utility/character.jsp
- The second is an hyphen (minus). cldr/utility/character.jsp
Bash with Hexdump Solution
Diff between Characters with an hex tool such as hexdump on Unix that output hexadecimal digits
Steps:
- The Character Set is UTF8. We got then hexadecimal in UTF8.
echo $LANG
en_US.UTF-8
- The Hexadecimal in UTF8 of the first character is e2 80 93. It corresponds to the unicode character 2013 - EN DASH. See Translation of a UTF-8 Multibyte sequence to Unicode - Example 2. 0a is the end of file.
echo – | hexdump -C
00000000 e2 80 93 0a |....|
00000004
- The Hexadecimal in UTF8 of the first character is 2d. This is the unicode character 2d - Hyphen Minus
echo - | hexdump -C
00000000 2d 0a |-.|
00000002