check-stateless

来自「libiconv是一个很不错的字符集转换库。程序接口也很简单」· 代码 · 共 34 行

TXT
34
字号
#!/bin/sh# Complete check of a stateless encoding.# Usage: check-stateless SRCDIR CHARSETsrcdir="$1"charset="$2"set -e# iconv in one direction../table-from "$charset" > tmp-"$charset".TXT# iconv in the other direction../table-to "$charset" | sort > tmp-"$charset".INVERSE.TXT# Check 1: charmap and iconv forward should be identical.cmp "${srcdir}"/"$charset".TXT tmp-"$charset".TXT 2> /dev/null# Check 2: the difference between the charmap and iconv backward.sed -e '/	.* 0x/d' < "${srcdir}"/"$charset".TXT > tmp-noprecomposed-"$charset".TXTif test -f "${srcdir}"/"$charset".IRREVERSIBLE.TXT; then  cat tmp-noprecomposed-"$charset".TXT "${srcdir}"/"$charset".IRREVERSIBLE.TXT | sort | uniq -u > tmp-orig-"$charset".INVERSE.TXTelse  cp tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXTficmp tmp-orig-"$charset".INVERSE.TXT tmp-"$charset".INVERSE.TXT 2> /dev/nullrm -f tmp-"$charset".TXT tmp-"$charset".INVERSE.TXT tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXTexit 0# For a new encoding:# You can create the "$charset".TXT like this:#   ./table-from "$charset" > "$charset".TXT# You can create the "$charset".IRREVERSIBLE.TXT like this:#   ./table-to "$charset" | sort > "$charset".INVERSE.TXT#   diff "$charset".TXT "$charset".INVERSE.TXT | grep '^[<>]' | sed -e 's,^. ,,' > "$charset".IRREVERSIBLE.TXT

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?