-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpc
executable file
·61 lines (53 loc) · 1.37 KB
/
cpc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -euo pipefail
diff() {
local f1=data/$1-glyphs.txt
local f2=data/$2-glyphs.txt
echo Added
comm -13 <(cut -d ' ' -f 1 "$f1") <(cut -d ' ' -f 1 "$f2")
echo
echo Removed
comm -23 <(cut -d ' ' -f 1 "$f1") <(cut -d ' ' -f 1 "$f2")
}
diffText() {
diff "$1" "$2" | python codepoints2text.py
}
available() {
local codepoints
codepoints=$(echo "$1" | python text2codepoints.py)
local result
result=$(_availableImpl "$(echo a | python text2codepoints.py)")
for cp in $codepoints; do
local thisResult
thisResult=$(_availableImpl "$cp")
result=$(echo "$result" "$thisResult" | tr ' ' '\n' | sort | uniq -d)
done
echo "$result" | tr ' ' '\n'
}
_availableImpl() {
local f
grep -l "$1" data/*-glyphs.txt | while IFS= read -r f; do
f=${f##*/}
f=${f%%-*}
echo "$f"
done
}
if (($# == 0)); then
cat <<EOF
Usage: $(basename "$0") COMMAND [ARGS...]
Commands:
diff PLATFORM1 PLATFORM2
List glyphs available in just one of the specified platforms, in
U+xxxxxx format
diffText PLATFORM1 PLATFORM2
List glyphs available in just one of the specified platforms, as
plain text
available TEXT
List the platforms on which all codepoints in the specified text are
available
EOF
exit 1
fi
cmd=$1
shift
$cmd "$@"