On 2015/02/02 01:12, Peter Haworth wrote:
I'm new to the unicode world so this question may not make sense.
The "PRAGMA encoding" statement tells me the encoding of a database. Can I
rely on all data in the database having that encoding? For example, if the
encoding is UTF8 and a row is inserted containing UTF16 encoded data, will
it still end up as UTF8 data in the database?
Not exactly sure if I understand what you are asking, so this answer may make
even less sense!
If you are asking whether or not you can rely on the data which you do not control, inside a DB set to UTF-8, to always be UTF-8,
then the simple answer is: Obviously not, it holds whatever the user (or program using the DB) stores in there however he/she/it
stores it. What the encoding means simply is that the database engine (SQLite in this case) will treat the data in the database as
if it is UTF-8 data. It will store, compare, collate, order, extract and do all the other things with the expectation that the data
will conform to the UTF-8 standard and as such return to you (the user) valid UTF-8 based answers.
None of this prevents you from sticking a BLOB or some UTF-16 or indeed any other Unicode text in there but you might find the
storing and returning of the values and query answers are not exactly what you expected with the format being somewhat off.
In short, the UTF-8 Pragma settings /allows/ your data to be interpreted as such. It doesn't /force/ it, nor magically /converts/
the data into UTF-8, and it most certainly does not under any circumstances *guarantee* the UTF-8-ness of data. (Though it does
guarantee that /IF/ you put valid UTF-8 data in there, it will be handled and returned correctly).
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users