Hello, i'am trying to generated all unicode 16.0 characters on a file and all unicode 15.1 characters on a other file and display on a new file the added characters on unicode 16.0. I tried this code, but this is not what im looking for, because there may be new emojis or others characters that may not be displayed on unicode 15.1 but is on unicode 16.0 and i dont think ive generated characters correctly. Please take a look on the source code, thank you.
import os
file_15_1 = "unicode_15_1.txt"
file_16_0 = "unicode_16_0.txt"
file_new_in_16_0 = "new_in_16_0.txt"
unicode_15_1_end = 149813
unicode_16_0_end = 154998
def is_visible(char):
return char.isprintable() and not char.isspace() and char != ""
def generate_unicode_file(start, end, filename):
with open(filename, "w", encoding="utf-8") as f:
for codepoint in range(start, end + 1):
try:
f.write(chr(codepoint) + "\n")
except ValueError:
continue
generate_unicode_file(0, unicode_15_1_end, file_15_1)
generate_unicode_file(0, unicode_16_0_end, file_16_0)
def find_new_characters(file1, file2, output_file):
with open(file1, "r", encoding="utf-8") as f1, open(file2, "r", encoding="utf-8") as f2:
chars_15_1 = set(f1.read().splitlines())
chars_16_0 = set(f2.read().splitlines())
new_in_16_0 = chars_16_0 - chars_15_1
with open(output_file, "w", encoding="utf-8") as f_out:
for char in sorted(new_in_16_0):
if is_visible(char):
f_out.write(char + "\n")
for char in sorted(new_in_16_0):
if not is_visible(char):
f_out.write(f"U+{ord(char):04X}\n")
find_new_characters(file_15_1, file_16_0, file_new_in_16_0)
print("Fichiers générés :")
print(f"- {file_15_1}")
print(f"- {file_16_0}")
print(f"- {file_new_in_16_0}")```