(Feb-21-2019, 10:51 AM)AlekseyPython Wrote: When in Python I convert the English- Russian string to koi8-r, I get a strange sequence:It's not strange you convert to bytes,in Python 3 are as string(text) Unicode bye default.
Moving to Python 3 Unicode was one the biggest changes.
>>> utf = 'My string, Моя строка' >>> koi = utf.encode(encoding='koi8-r', errors='ignore') >>> koi b'My string, \xed\xcf\xd1 \xd3\xd4\xd2\xcf\xcb\xc1' >>> koi.decode() # Default here is the same as koi.decode('utf-8') Traceback (most recent call last): File "<interactive input>", line 1, in <module> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 11: invalid continuation byte # Has to use same encoding to get it back to default text(Unicode) Python 3 # Should try to use utf-8 always,makes it better for everyone >>> koi.decode('koi8-r') 'My string, Моя строка'I don't see a reason why you should mess with this at all.
Try avoid encoding/decoding at all,let DB handle if needed.
If example test sqlite3 with Python 3.7.
There is no need to do anything,Python 3 text(Unicode default) will go in out DB without any problems.
E:\div_code\xy λ ptpython -i dbb.py >>> bid = Bidbase() >>> bid.create_db() >>> bid.insert('gleen mars', '345678') >>> utf = 'My string, Моя строка' >>> bid.insert('foo', utf) >>> bid.read_all() gleen mars : 345678 foo : My string, Моя строка