gen.py 569 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Generates the unidecode.dat module
  4. # (c) 2010 Andreas Rumpf
  5. from unidecode import unidecode
  6. try:
  7. import warnings
  8. warnings.simplefilter("ignore")
  9. except ImportError:
  10. pass
  11. def main():
  12. f = open("unidecode.dat", "wb+")
  13. for x in range(128, 0xffff + 1):
  14. u = eval("u'\\u%04x'" % x)
  15. val = unidecode(u)
  16. # f.write("%x | " % x)
  17. if x == 0x2028: # U+2028 = LINE SEPARATOR
  18. val = ""
  19. elif x == 0x2029: # U+2029 = PARAGRAPH SEPARATOR
  20. val = ""
  21. f.write("%s\n" % val)
  22. f.close()
  23. main()