Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/src/runetype/compose.rc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

if(~ $#rune 0){
	echo 'need runesize defined (see mkfile)' >[1=2]
	exit runesize
}
if(~ $#uconv 0)
	uconv=8.uconv
unicodedata = unicodedata
for(i)
	unicodedata = $i

fn Sprint {
	$uconv
}

fn Unicode {
	grep $rune < $unicodedata | tr -d '\015'
}

hex='
function hex0(s,        base, r, n, i, k, c)
{
	base = 16;
	if(s ~ /^0[xX]/)
		s = substr(str, 3);
	if(s !~ /^[0-9a-fA-f]*/)
		return 0;
	n = length(s)
  	r = 0
	for (i = 1; i <= n; i++) {
		c = tolower(substr(s, i, 1))
		k = index("0123456789abcdef", c) - 1;
		r = r * base + k
	}
     	return r
}
'
awk '-F;' '
' ^ $hex ^ '

function hex(x){
	return strtonum("0x" x);
}

BEGIN {
}

length($6)>0 && $6 !~ /^</ {
	split($6, a, " ");
	if(length(a) != 2)
		next
#	combiner[hex(a[2])]++;
	idx = hex(a[1])*65536 + hex(a[2])
	tab[idx] = hex($1);
}

END {
	print "static";
	print "uint\t__combine2[] =";
	print "{";

	for(i in tab){
		printf "\t" "0x%08x," "\t" "0x%04x," "\t /* \\u%04x + %04x -> \\u%04x */\n", 
			i, tab[i], i/65536, i%65536, tab[i] | "sort"
	}
	close "sort"
	print "};"
	print ""
#	for(i in combiner)
#		printf "//	\\u%04x %04x %d\n", i, i, combiner[i]
#	print ""
} ' <{Unicode} | Sprint

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].