Re: [pysqlite] Avoid conversion to unicode for APSW
"Nemanja Čorlija" <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Apr 15, 2008 at 11:28 PM, Roger Binns <[email protected]> wrote: > Note that the database you have created is invalid since SQLite says the > strings are UTF-8. It is a bug in SQLite that it didn't ensure that in > the first place. > I don't think SQLite says that strings *are* utf-8. I think behavior is intentional, somewhat documented and unlikely to change any time soon. In fact SQLite3 overview page has this to say about support for UTF-8 and UTF-16: SQLite is not particular about the text it receives and is more than happy to process text strings that are not normalized or even well-formed UTF-8 or UTF-16. Thus, programmers who want to store IS08859 data can do so using the UTF-8 interfaces. As long as no attempts are made to use a UTF-16 collating sequence or SQL function, the byte sequence of the text will not be modified in any way. http://www.sqlite.org/version3.html > You can solve your problem using one of the functions available in > SQLite. For example: > > select hex(col) from table > > You can then convert that to bytes: > > def hex2str(val): > return "".join([ chr (int(val[i:i+2],16)) > for i in range(0,len(val),2) ]) > Thanks for the suggestion. I will keep that as my last resort. -- Nemanja Čorlija <[email protected]> _______________________________________________ list-pysqlite mailing list [email protected] http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite