summaryrefslogtreecommitdiff
path: root/tests/gen-all-unicode.py
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-05-19 14:15:35 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2017-05-19 17:32:28 +0100
commit386939f9d576e8ac956f88fd85f87d1fba76e9ed (patch)
tree5eec82eaab7e3547741630daf9d944e627186a62 /tests/gen-all-unicode.py
parent09623d50ac8afd9b246e571372972142af5daaa3 (diff)
downloadpango-386939f9d576e8ac956f88fd85f87d1fba76e9ed.tar.gz
meson: Install tests and additional data
Diffstat (limited to 'tests/gen-all-unicode.py')
-rw-r--r--tests/gen-all-unicode.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/gen-all-unicode.py b/tests/gen-all-unicode.py
new file mode 100644
index 00000000..011ab9d2
--- /dev/null
+++ b/tests/gen-all-unicode.py
@@ -0,0 +1,34 @@
+import sys
+
+# From glib/gutf8.c:
+#
+#define UNICODE_VALID(Char) \
+# ((Char) < 0x110000 && (((Char) & 0xFFFFF800) != 0xD800))
+
+def is_valid_unicode(ch):
+ if ch < 0x110000 and (ch & 0xFFFFF800) != 0xD800:
+ return True
+
+ return False
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ sys.exit('Usage: gen-all-unicode.py OUTFILE')
+
+ with open(sys.argv[1], 'wb') as f:
+ for j in range(0, 2):
+ for i in range(0, 65536):
+ if is_valid_unicode(i):
+ f.write(chr(i).encode('utf-8', 'surrogatepass'))
+
+ if j == 1:
+ f.write(b' ')
+
+ if j == 0:
+ if i % 40 == 0 and i != 0:
+ f.write(b'\n')
+ else:
+ if i % 20 == 0 and i != 0:
+ f.write(b'\n')
+
+ f.write(b'\n')