Re: pysqlite design decisions
Roger Binns <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 glyph-TyWPi3/[email protected] wrote: | What I really want to return is a mutable octet array, but Python's | array module is not widely used or understood (and is missing many | useful convenience functions that are present on str). We'll have to agree to disagree. I still think str is really bad object to store blobs in. It is ok to temporarily convert behind the scenes into str because of what various APIs require etc. | That's an interesting motivation. In retrospect, I personally would | still have made it explicit, rather than based on the string's content, | what type apsw would return for strings (especially since if you had a | database manipulated with the Unicode version and you attempted to open | it with the ANSI version... what happens?) but I suppose hindsight is 20/20. It all works perfectly because ASCII is a subset of UTF-8. So providing you never put any non-ASCII data in, you would never get non-ASCII out. Sure you run a Unicode version of BitPim and then enter Unicode characters, save them to the database, and then reopen with the ANSI version of BitPim. At that point apsw would return Unicode strings for those particular fields and then ANSI wxPython would say it has no idea what to do with the Unicode strings. But if you could run the Unicode version anyway, why bother with the ANSI version. This scheme only really has trouble if there are other encodings that are a subset of UTF-8. One example you gave is punycode. But it wasn't in use much by Python people back then, nor was that much code Unicode aware. Hence the decision to make it work simply for all-ASCII code as well as Unicode aware code. And now that times have changed, I am fixing the next release to only return Unicode :-) Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFeR80mOOfHg372QQRAtzKAKCUAbbuyFi8IXYJq0tEGTaD3kav2ACfR+GS YRrJMZE69Tj6Qd+v6AzHBUY= =idV2 -----END PGP SIGNATURE-----