summaryrefslogtreecommitdiff
path: root/src/font/iso8859_2_to_utf32.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/font/iso8859_2_to_utf32.py')
-rw-r--r--src/font/iso8859_2_to_utf32.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/font/iso8859_2_to_utf32.py b/src/font/iso8859_2_to_utf32.py
new file mode 100644
index 0000000..664239b
--- /dev/null
+++ b/src/font/iso8859_2_to_utf32.py
@@ -0,0 +1,18 @@
+from encodings import iso8859_2
+
+table = []
+
+for ch in iso8859_2.decoding_table: # length = 256
+ if ch == '\ufffd': # undefined bytes (if any)
+ table.append(0x0000) # or 0xFFFD if you prefer
+ else:
+ table.append(ord(ch))
+
+print("static const uint32_t iso8859_2_to_utf32[256] = {")
+for i, v in enumerate(table):
+ if i % 8 == 0:
+ print(" ", end="")
+ print(f"0x{v:04X}, ", end="")
+ if i % 8 == 7:
+ print()
+print("\n};")