fixes #8768 properly

This commit is contained in:
Araq 2018-08-30 16:54:03 +02:00
commit dfdf8e58c7
3 changed files with 18 additions and 17 deletions

View file

@ -1,26 +1,30 @@
#! usr/bin/env python #! usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generates the unidecode.dat module # Generates the unidecode.dat module
# (c) 2010 Andreas Rumpf # (c) 2010 Andreas Rumpf
from unidecode import unidecode from unidecode import unidecode
import warnings try:
import warnings
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
except ImportError:
pass
def main2(): def main2():
data = [] f = open("unidecode.dat", "wb+")
for x in range(128, 0xffff + 1): for x in range(128, 0xffff + 1):
u = eval("u'\\u%04x'" % x) u = eval("u'\\u%04x'" % x)
val = unidecode(u) val = unidecode(u)
data.append(val)
f = open("unidecode.dat", "w+") # f.write("%x | " % x)
for d in data: if x==0x2028: # U+2028 = LINE SEPARATOR
f.write("%s\n" % d) val = ""
elif x==0x2029: # U+2028 = PARAGRAPH SEPARATOR
val = ""
f.write("%s\n" % val)
f.close() f.close()
main2()
main2()

View file

@ -8109,9 +8109,6 @@ _
%0 %0
%00 %00

View file

@ -68,6 +68,6 @@ proc unidecode*(s: string): string =
elif c <% translationTable.len: add(result, translationTable[c-128]) elif c <% translationTable.len: add(result, translationTable[c-128])
when isMainModule: when isMainModule:
loadUnidecodeTable("lib/pure/unidecode/unidecode.dat") #loadUnidecodeTable("lib/pure/unidecode/unidecode.dat")
doAassert unidecode("Äußerst") == "Ausserst" doAssert unidecode("Äußerst") == "Ausserst"
doAssert unidecode("北京") == "Bei Jing" doAssert unidecode("北京") == "Bei Jing "