sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

canvas.c2w.list-ucsver-detection-codes.sh (2889B)


      1 #!/bin/bash
      2 
      3 if ! declare -f ble/unicode/EmojiStatus &>/dev/null; then
      4   source out/ble.sh --lib
      5 fi
      6 
      7 # ble/unicode/EmojiStatus 128512; echo $ret
      8 # ble/unicode/EmojiStatus 128529; echo $ret
      9 # ble/unicode/EmojiStatus 128533; echo $ret
     10 # ble/unicode/EmojiStatus 128535; echo $ret
     11 # ble/unicode/EmojiStatus 128537; echo $ret
     12 # ble/unicode/EmojiStatus 128539; echo $ret
     13 # ble/unicode/EmojiStatus 128543; echo $ret
     14 # ble/unicode/EmojiStatus 128550; echo $ret
     15 # ble/unicode/EmojiStatus 128556; echo $ret
     16 # ble/unicode/EmojiStatus 128558; echo $ret
     17 # ble/unicode/EmojiStatus 128564; echo $ret
     18 
     19 function list-range-code-for-version-detection {
     20   local nversion=$_ble_unicode_c2w_UnicodeVersionCount
     21   local _ble_unicode_c2w_ambiguous=3
     22   local ver ret prev_ver
     23   for ((ver=1;ver<nversion;ver++)); do
     24     prev_ver=$((ver-1))
     25 
     26     local code
     27     for code in "${!_ble_unicode_c2w[@]}"; do
     28       ble/unicode/EmojiStatus "$code"
     29       ((ret)) && continue
     30       local -a _ble_unicode_c2w_custom=()
     31       _ble_unicode_c2w_version=$prev_ver ble/unicode/c2w "$code"; local oldw=$ret
     32       _ble_unicode_c2w_version=$ver ble/unicode/c2w "$code"; local neww=$ret
     33       ble/util/unlocal _ble_unicode_c2w_custom
     34       ((oldw==neww||oldw==3&&neww>0||neww==3&&oldw>0)) && continue
     35 
     36       ble/util/c2s "$code"; local ch=$ret
     37 
     38       local note=
     39       if [[ ${_ble_unicode_c2w_custom[code]} ]]; then
     40         note="${note:+$note, }overwritten by wcwidth-custom"
     41       fi
     42 
     43       printf 'ver%s U+%04X(%d) %s %d->%d (%s)%s\n' \
     44              "$ver" "$code" "$code" "$ch" \
     45              "$oldw" "$neww" "${_ble_unicode_c2w_UnicodeVersionMapping[*]:_ble_unicode_c2w[code]*nversion:nversion}" \
     46              "${note:+ # $note}"
     47     done
     48   done
     49 
     50   printf '               | %-*s|musl\n' "$((nversion*3))" '-----Unicode EAW+GeneralCategory'
     51   local -a keys=(
     52     U+9FBC  U+9FC4  U+31B8  U+D7B0
     53     U+3099  U+9FCD  U+1F93B U+312E
     54     U+312F  U+16FE2 U+32FF  U+31BB
     55     U+9FFD  U+1B132)
     56   local code index=0 ret
     57   for code in "${keys[@]}"; do
     58     ((code=16#${code#U+}))
     59     ble/unicode/EmojiStatus "$code"
     60     if ((ret)); then
     61       printf 'U+%04X: emoji cannot be used to detect the Unicode version\n' "$code" >&2
     62       continue
     63     fi
     64 
     65     local c2w=${_ble_unicode_c2w[code]}
     66     if [[ ! $c2w ]]; then
     67       local c=$code
     68       until [[ $c2w || c -eq 0 ]]; do c2w=${_ble_unicode_c2w[--c]}; done
     69       if [[ $c2w ]]; then
     70         printf 'U+%04X: warning: not c2w boundary. borrow the data of boundary U+%04X\n' "$code" "$c" >&2
     71       else
     72         printf 'U+%04X: this is not c2w boundary\n' "$code" >&2
     73         continue
     74       fi
     75     fi
     76 
     77     local width_vec=$(printf ' %2d' "${_ble_unicode_c2w_UnicodeVersionMapping[@]:c2w*nversion:nversion}")
     78     ble/util/c2w:musl "$code"; local c2w_musl=$ret
     79     printf '%-6s U+%05X |%s |%2d\n' "ws[$((index++))]" "$code" "$width_vec" "$c2w_musl"
     80   done
     81 }
     82 list-range-code-for-version-detection