1234567891011121314151617181920 |
- # shellcheck shell=sh
- # unicode to hex
- u2x() (
- for u; do
- # shellcheck disable=2005,2046
- printf '%s\n' $(
- printf %b "${u}" |
- iconv -f UTF-8 -t UTF-16 |
- od --endian=big -An -N2 -x
- )
- done
- )
- # hex to unicode
- x2u() {
- # shellcheck disable=2046
- [ "${1:-}" ] && printf '%b\n' $(printf '\\u%s\n' "${@}")
- }
|