D1645.check-c2w-table.sh (2025B)
1 #!/bin/bash 2 3 source out/data/c2w.eaw-13.0.0.sh 4 source src/canvas.c2w.sh 5 6 function dump { 7 local out= i=0 8 arr=() 9 for ((c=0;c<0x110000;c++)); do 10 "$1" "$c"; out="$out $ret" 11 if (((c+1)%32==0)); then 12 arr[i++]=$out 13 out= 14 fi 15 done 16 printf '%s\n' "${arr[@]}" 17 } 18 19 function c2w.binary { 20 local c=$1 21 ret=${_ble_unicode_EastAsianWidth_c2w[c]} 22 [[ $ret ]] && return 0 23 24 local l u m 25 ((l=0,u=${#_ble_unicode_EastAsianWidth_c2w_ranges[@]}-1)) 26 27 while ((l+1<u)); do 28 ((m=(l+u)/2)) 29 if ((_ble_unicode_EastAsianWidth_c2w_ranges[m]<=c)); then 30 l=$m 31 else 32 u=$m 33 fi 34 done 35 ret=${_ble_unicode_EastAsianWidth_c2w[_ble_unicode_EastAsianWidth_c2w_ranges[l]]} 36 } 37 38 function c2w.bindex { 39 local c=$1 40 ret=${_ble_unicode_EastAsianWidth_c2w[c]} 41 [[ $ret ]] && return 0 42 43 ret=${_ble_unicode_EastAsianWidth_c2w_index[c<0x20000?c>>8:((c>>12)-32+512)]} 44 if [[ $ret == *:* ]]; then 45 local l=${ret%:*} u=${ret#*:} m 46 while ((l+1<u)); do 47 ((m=(l+u)/2)) 48 if ((_ble_unicode_EastAsianWidth_c2w_ranges[m]<=c)); then 49 l=$m 50 else 51 u=$m 52 fi 53 done 54 ret=${_ble_unicode_EastAsianWidth_c2w[_ble_unicode_EastAsianWidth_c2w_ranges[l]]} 55 fi 56 } 57 58 function c2w.unified { 59 local c=$1 60 ret=${_ble_unicode_c2w[c]} 61 if [[ ! $ret ]]; then 62 ret=${_ble_unicode_c2w_index[c<0x20000?c>>8:((c>>12)-32+512)]} 63 if [[ $ret == *:* ]]; then 64 local l=${ret%:*} u=${ret#*:} m 65 while ((l+1<u)); do 66 ((m=(l+u)/2)) 67 if ((_ble_unicode_c2w_ranges[m]<=c)); then 68 l=$m 69 else 70 u=$m 71 fi 72 done 73 ret=${_ble_unicode_c2w[_ble_unicode_c2w_ranges[l]]} 74 fi 75 fi 76 ret=${_ble_unicode_c2w_UnicodeVersionMapping[ret*_ble_unicode_c2w_UnicodeVersionCount+_ble_unicode_c2w_version]} 77 } 78 79 #time dump c2w.binary > out/data/c2w.eaw-13.0.0.impl1.dump 80 #time dump c2w.bindex > out/data/c2w.eaw-13.0.0.impl2.dump 81 82 ble/unicode/c2w/version2index 13.0 83 _ble_unicode_c2w_version=$ret 84 time dump c2w.unified > out/data/c2w.eaw-13.0.0.impl3.dump