From ed459bfb63c58b59fc0dbe25021c396e8ef8683c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 20 Jan 2012 17:24:05 -0500 Subject: [PATCH] Add hb-unicode-encode --- test/shaping/hb-unicode-encode | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 test/shaping/hb-unicode-encode diff --git a/test/shaping/hb-unicode-encode b/test/shaping/hb-unicode-encode new file mode 100755 index 000000000..02609be83 --- /dev/null +++ b/test/shaping/hb-unicode-encode @@ -0,0 +1,22 @@ +#!/usr/bin/python + +import sys +import re + +def encode (s): + s = re.sub (r"[<+>\\uU]", " ", s) + s = re.sub (r"0[xX]", " ", s) + return u''.join (unichr (int (x, 16)) for x in re.split ('[, \n]', s) if len (x)) + +if __name__ == '__main__': + + if len (sys.argv) == 1 or ('--stdin' in sys.argv and len (sys.argv) != 2): + print "Usage:\n %s UNICODE_CODEPOINTS...\nor:\n %s --stdin" % (sys.argv[0], sys.argv[0]) + sys.exit (1) + + if '--stdin' in sys.argv: + sys.argv.remove ('--stdin') + for line in sys.stdin.readlines (): + print encode (line) + else: + print encode (','.join (sys.argv[1:]))