On Mon, Jan 13, 2020 at 1:10 PM Keith Medcalf <kmedc...@dessus.com> wrote:
> If the register object contains "text" and you cast it to a blob (remove the 
> text affinity) you are left with just the bag-o-bytes, and length() will 
> return the size of the bag encoded in the register.  If the data in the 
> register is other than type "text" then it must be converted to text first 
> (in the database encoding) and then the cast will remove the text affinity, 
> after which the value returned by the length() function will be the number of 
> bytes in the bag that holds that text representation:
>
> sqlite> pragma encoding='utf-16';
> sqlite> create table x(x);
> sqlite> insert into x values ('text' || char(0) || 'text');
> sqlite> select x, typeof(x), length(x), length(cast(x as blob)) from x;
> text|text|4|18

Please remind me, is the encoding a "client-side" setting, or also a
"server-side" (i.e. stored) setting?

I wasn't sure whether pragma encoding='utf-16' affected the stored
state as well, or whether it was always in UTF-8
and SQLite was doing conversion on the fly for the client requested
encoding. I thought of lengthof() as the size stored
in the value header itself, which I assumed was always in bytes.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to