mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 02:42:05 +00:00
fixes #8768 properly
This commit is contained in:
@@ -1,26 +1,30 @@
|
||||
#! usr/bin/env python
|
||||
#! usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Generates the unidecode.dat module
|
||||
# (c) 2010 Andreas Rumpf
|
||||
|
||||
from unidecode import unidecode
|
||||
import warnings
|
||||
|
||||
warnings.simplefilter("ignore")
|
||||
try:
|
||||
import warnings
|
||||
warnings.simplefilter("ignore")
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def main2():
|
||||
data = []
|
||||
f = open("unidecode.dat", "wb+")
|
||||
for x in range(128, 0xffff + 1):
|
||||
u = eval("u'\\u%04x'" % x)
|
||||
|
||||
val = unidecode(u)
|
||||
data.append(val)
|
||||
|
||||
f = open("unidecode.dat", "w+")
|
||||
for d in data:
|
||||
f.write("%s\n" % d)
|
||||
# f.write("%x | " % x)
|
||||
if x==0x2028: # U+2028 = LINE SEPARATOR
|
||||
val = ""
|
||||
elif x==0x2029: # U+2028 = PARAGRAPH SEPARATOR
|
||||
val = ""
|
||||
f.write("%s\n" % val)
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
main2()
|
||||
main2()
|
||||
@@ -8109,9 +8109,6 @@ _
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%0
|
||||
%00
|
||||
|
||||
@@ -68,6 +68,6 @@ proc unidecode*(s: string): string =
|
||||
elif c <% translationTable.len: add(result, translationTable[c-128])
|
||||
|
||||
when isMainModule:
|
||||
loadUnidecodeTable("lib/pure/unidecode/unidecode.dat")
|
||||
doAassert unidecode("Äußerst") == "Ausserst"
|
||||
doAssert unidecode("北京") == "Bei Jing"
|
||||
#loadUnidecodeTable("lib/pure/unidecode/unidecode.dat")
|
||||
doAssert unidecode("Äußerst") == "Ausserst"
|
||||
doAssert unidecode("北京") == "Bei Jing "
|
||||
|
||||
Reference in New Issue
Block a user