Reading Unicode From Sqlite Db Using Python
The data stored in unicode (in database) has to be retrieved and convert into a different form. The following snippet def convert(content): content = content.replace('ஜௌ',
Solution 1:
content = content.replace("ஜௌ", "n\[s");
Suggest you mean:
content = content.replace(u'ஜௌ', ur'n\[s');
or for safety where the encoding of your file is uncertain:
content = content.replace(u'\u0B9C\u0BCC', ur'n\[s');
The content you have is already Unicode, so you should do Unicode string replacements on it. "ஜௌ"
without the u
is a string of bytes that represents those characters in some encoding dependent on your source file charset. (Byte strings work smoothly together with Unicode strings only in the most unambiguous cases, which is for ASCII characters.)
(The r
-string means not having to worry about including bare backslashes.)
Post a Comment for "Reading Unicode From Sqlite Db Using Python"