]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/rus/lat2rus.py
Fix encodings in m_lib/rus
[m_lib.git] / m_lib / rus / lat2rus.py
index 4e3d5805b4d4a6c98dd5683ebcf10cdaaeb8b70e..86d01070765f1e4f57bb90a8c71f7ca47e786e5d 100755 (executable)
@@ -2,6 +2,7 @@
 # -*- coding: koi8-r -*-
 
 from __future__ import print_function
+from ..lazy.dict import LazyDictInitFunc
 
 #
 # Lat -> Rus translation
@@ -81,26 +82,25 @@ lat2koi_d = {
    "%": ":",
    "^": ",",
    "&": ".",
-   "*": ";"
+   "*": ";",
 }
 
 
 def make_lat2xxx(encoding="cp1251"):
    d = {}
    for k, v in lat2koi_d.items():
-      v = unicode(v, "koi8-r").encode(encoding)
       d[k] = v
    return d
 
 
-from m_lib.lazy.dict import LazyDictInitFunc
 lat2win_d = LazyDictInitFunc(make_lat2xxx, encoding="cp1251")
 
 
 def lat2rus(instr, lat2rus_d = lat2koi_d):
    out = []
    for c in instr:
-      out.append(lat2rus_d.get(c, c))
+      c = lat2rus_d.get(c, c)
+      out.append(c)
    return ''.join(out)
 
 
@@ -114,4 +114,5 @@ if __name__ == "__main__":
    Test = "Ghbdtn nt,t^ ghtrhfcysq vbh!"
    print("Test:", Test)
    print("Тест:", lat2koi(Test))
-   print("Тест:", unicode(lat2win(Test), "cp1251").encode("koi8-r"))
+   test = lat2win(Test)
+   print("Тест:", test)