mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
faa3cc195d
- As suggested by Arseniy Zarche - Also updated confusables to Unicode 12
39 lines
868 B
Python
39 lines
868 B
Python
# Needs UnicodeData.txt in the current directory.
|
|
#
|
|
# It can be obtained from unicode.org:
|
|
# - http://www.unicode.org/Public/<VERSION>/ucd/UnicodeData.txt
|
|
#
|
|
# If executed as a script, it will generate the contents of the file
|
|
# `src/base/unicode/tolower_data.h`.
|
|
|
|
import unicode
|
|
|
|
def generate_cases():
|
|
ud = unicode.data()
|
|
return [(unicode.unhex(u["Value"]), unicode.unhex(u["Simple_Lowercase_Mapping"])) for u in ud if u["Simple_Lowercase_Mapping"]]
|
|
|
|
def main():
|
|
cases = generate_cases()
|
|
|
|
print("""\
|
|
#include <stdint.h>
|
|
|
|
struct UPPER_LOWER
|
|
{{
|
|
\tint32_t upper;
|
|
\tint32_t lower;
|
|
}};
|
|
|
|
enum
|
|
{{
|
|
\tNUM_TOLOWER={},
|
|
}};
|
|
|
|
static const struct UPPER_LOWER tolower[NUM_TOLOWER] = {{""".format(len(cases)))
|
|
for upper_code, lower_code in cases:
|
|
print("\t{{{}, {}}},".format(upper_code, lower_code))
|
|
print("};")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|