Jump to content

User:Psiĥedelisto/BashUnicodeDAB

From Wikipedia, the free encyclopedia

Bash Unicode Disambiguator

[edit]

It is impossible for me to differentiate 8′46″ and 8'46". One has a prime/double prime, the other an ASCII apostrophe (U+27)/straight quotation mark (U+22). Even with screen magnifier, can't see a difference. This was previously an unknown unknown for me, so I made this page for my reference, as I'll likely need to deal with this again, as many confusables exist.

Workaround

[edit]

BashUnicodeDAB.sh

[edit]
#!/bin/bash
# BashUnicodeDAB.sh
# Send EOF to exit.
while read -e -a S
do
    S="${S//\"/\\\\\"}"
    printf 'import unicodedata as ud\nprint([ud.name(c) for c in """'${S}'"""])' | /usr/bin/python
done

Example run

[edit]

^D == End-of-file

Fred@DESKTOP-CBDJO68 MSYS /d
$ ./BashUnicodeDAB.sh
8′46″
['DIGIT EIGHT', 'PRIME', 'DIGIT FOUR', 'DIGIT SIX', 'DOUBLE PRIME']
8'46"
['DIGIT EIGHT', 'APOSTROPHE', 'DIGIT FOUR', 'DIGIT SIX', 'QUOTATION MARK']

[]
^D