#! /bin/sh # generate list of ranges of wide characters, i.e. # East Asian categories Wide (W) and FullWidth (F), from EastAsianWidth.txt, # plus enclosing ranges as listed in Blocks.txt if make Blocks.txt >&2 then true else echo Could not acquire Unicode data file Blocks.txt >&2 exit 1 fi if make EastAsianWidth.txt >&2 then true else echo Could not acquire Unicode data file EastAsianWidth.txt >&2 exit 1 fi sed -e "s,^\([^;]*\);[WF],\1," -e t -e d EastAsianWidth.txt > width-w #uniset +width-w c > wide.h #rm -f width-w sed -e "s, .*,," width-w > width-w.lst rm -f width-w function isawidechar () { grep -w $1 width-w.lst > /dev/null } function hasawidechar () { chk=`printf %d 0x$1` end=`printf %d 0x$2` limit=`expr $chk + 222` if [ $limit -lt $end ] then end=$limit fi while [ $chk -le $end ] do if isawidechar `printf %04X $chk` then return 0 fi chk=`expr $chk + 1` done return 9 } sed -e "s,^\([0-9A-F][0-9A-F]*\)[^0-9A-F][^0-9A-F]*\([0-9A-F][0-9A-F]*\);.*,\1 \2," \ -e t -e d Blocks.txt | while read block do if hasawidechar $block then set - $block echo " {0x$1, 0x$2}," fi done rm -f width-w.lst