-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
D1645.check-c2w-table.sh
executable file
·84 lines (74 loc) · 1.98 KB
/
D1645.check-c2w-table.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
source out/data/c2w.eaw-13.0.0.sh
source src/canvas.c2w.sh
function dump {
local out= i=0
arr=()
for ((c=0;c<0x110000;c++)); do
"$1" "$c"; out="$out $ret"
if (((c+1)%32==0)); then
arr[i++]=$out
out=
fi
done
printf '%s\n' "${arr[@]}"
}
function c2w.binary {
local c=$1
ret=${_ble_unicode_EastAsianWidth_c2w[c]}
[[ $ret ]] && return 0
local l u m
((l=0,u=${#_ble_unicode_EastAsianWidth_c2w_ranges[@]}-1))
while ((l+1<u)); do
((m=(l+u)/2))
if ((_ble_unicode_EastAsianWidth_c2w_ranges[m]<=c)); then
l=$m
else
u=$m
fi
done
ret=${_ble_unicode_EastAsianWidth_c2w[_ble_unicode_EastAsianWidth_c2w_ranges[l]]}
}
function c2w.bindex {
local c=$1
ret=${_ble_unicode_EastAsianWidth_c2w[c]}
[[ $ret ]] && return 0
ret=${_ble_unicode_EastAsianWidth_c2w_index[c<0x20000?c>>8:((c>>12)-32+512)]}
if [[ $ret == *:* ]]; then
local l=${ret%:*} u=${ret#*:} m
while ((l+1<u)); do
((m=(l+u)/2))
if ((_ble_unicode_EastAsianWidth_c2w_ranges[m]<=c)); then
l=$m
else
u=$m
fi
done
ret=${_ble_unicode_EastAsianWidth_c2w[_ble_unicode_EastAsianWidth_c2w_ranges[l]]}
fi
}
function c2w.unified {
local c=$1
ret=${_ble_unicode_c2w[c]}
if [[ ! $ret ]]; then
ret=${_ble_unicode_c2w_index[c<0x20000?c>>8:((c>>12)-32+512)]}
if [[ $ret == *:* ]]; then
local l=${ret%:*} u=${ret#*:} m
while ((l+1<u)); do
((m=(l+u)/2))
if ((_ble_unicode_c2w_ranges[m]<=c)); then
l=$m
else
u=$m
fi
done
ret=${_ble_unicode_c2w[_ble_unicode_c2w_ranges[l]]}
fi
fi
ret=${_ble_unicode_c2w_UnicodeVersionMapping[ret*_ble_unicode_c2w_UnicodeVersionCount+_ble_unicode_c2w_version]}
}
#time dump c2w.binary > out/data/c2w.eaw-13.0.0.impl1.dump
#time dump c2w.bindex > out/data/c2w.eaw-13.0.0.impl2.dump
ble/unicode/c2w/version2index 13.0
_ble_unicode_c2w_version=$ret
time dump c2w.unified > out/data/c2w.eaw-13.0.0.impl3.dump