if len(S) >= Width:
return S
else:
- l = (Width - len(S)) / 2
+ l = (Width - len(S)) // 2
r = Width - len(S) - l
return Ch*l + S + Ch*r
return transl_adict[id][val]
-# Encodings, especially cyrillic. Requires Unicode, hence Python 2.0+
-
def recode(s, from_encoding, to_encoding, errors = "strict"):
- return unicode(s, from_encoding, errors).encode(to_encoding, errors)
+ if isinstance(s, bytes):
+ s = s.decode(from_encoding, errors)
+ return s.encode(to_encoding, errors)
def win2koi(s, errors = "strict"):