skia2/experimental/tools/generate-unicode-test-txt
Hal Canary b5680ca0d8 experimental/tools: minor code cleanup
Change-Id: I4d84dfed284aea9746808bf8a22f45e5bd9c519f
Reviewed-on: https://skia-review.googlesource.com/118597
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2018-04-05 14:16:02 +00:00

65 lines
3.1 KiB
Python
Executable File

#! /usr/bin/env python
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import array, zlib, base64, sys
## Source: http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt
valid_codepoint_data = '''
eNrt3buPG0UcwHHPeNf22b67hPBIUpAc0iEgElAgIkSRXEkXUVOcKKj5F6BFQpSUqSgpkUAU+Rco
+Av4PyLicD6ZzT5mZmfmtzPz/UhWFJ/X8356H/dmkHJGFgAAAADe6I73q55j1NXLJ0VRAAASHzN0
ouOcaol/zuPyKmJYdct7G9oMANqv01gKGScFpbUusN0ogbheCPSVb9KUkfFcQAceQ9XA3+YOfVJX
nHdrtaon3FBprA3SWwnnc9u/uuO4trjuymnZ8r3LkfHeWI4pKsIYZJOXLvWrKw27409H1tllo0ym
3v7H5GVb3FeNOhyyH1gPpHHekw/zg/dV4715x3eYqCzjscuLRaD5em05FsVo2z6+ez4iHcuW92vH
+rnynO6p5b9r2zXJ/2VHW7CJ18kE8zbW2tAkPZXg+tQlHF/lMg8cX9N5kh6IY9Vz7FAYC4cy3Bay
5qoEwjxvKXd1ML7bzskO68GY9qEG2nNfXdOO/cR9lv1B5z85tJdU80pFPvac5gK0tqV6xm+PAFDS
fHno3E3XfaVU0lhCvivqddGk82IeKZwFRR21/tDGAAAAkMtaomQu58H27TGEvO7zyPP3bUemXY34
HoRbqzYtPH/Otk34CgPDVgnFtaa4Wq0Fw7bdP68cPp/KvEZHHt9DiHWOlk2/Xuq8lj1kmd/ndIB6
vBCoAxdUn0n2faz5kcN8XLr+llb3HyZcdxTreSBb7M0AkFy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Zypvukw3d4+mrW5QRkJsp7wVrigcF
e4ssaPUHWRCMr+es/EhWesftm4fzRs+6n8ehHL5TUR5WdVKPqMNKOO6q4zNz6gAAsOYHQH8EAAAA
ZKTt9kpj9jqf9Jzg5GMPtW+e3veM7L+XlDXgc837PllozPS8z/21xE8r/32nqcN+VFuE3fY72+61
uEqXmr36W2tbWKrls2pm9zuvMoybS7rGlr8KFMYnV/+eJPZjZUX3MClboTFFCR0biss5t5KX7Zd2
jkOJ/c5nAmEeZ1gv9svJXxkuAAAAAACw4rJP0LdfdkSWZmVLFnj3wPLzue+Zrgw/t8gkHb59PeJY
ZZAm7fk7fdZvX49j+fDF69Fz+iYAABDHP/Vm9jbZIOpfwWoh0w==
'''
if sys.version_info[0] < 3:
def to_unicode(i):
return ('\\U%08x' % i).decode('unicode-escape').encode('UTF-8')
else:
def to_unicode(i):
return chr(i)
o = sys.stdout
o.write(to_unicode(0xFEFF))
pack = array.array('I', zlib.decompress(
base64.b64decode(valid_codepoint_data)))
i = 0
last_row = -1
plist = pack.tolist()
for increment in plist:
i += increment + 1
row = i - (i & 63)
if last_row != row:
if row:
o.write('\n' if row % 1024 else '\n\n')
o.write('U+%06x ' % row)
last_row = row
o.write(' ' + to_unicode(i))
o.write('\n')