On 2020/01/13 12:24 PM, Dominique Devienne wrote:
On Mon, Jan 13, 2020 at 11:07 AM Keith Medcalf <kmedc...@dessus.com> wrote:
On Monday, 13 January, 2020 02:27, Dominique Devienne <ddevie...@gmail.com> 
wrote:
I'd vote for a lengthof(col) that's always O(1) for both text and blob
So what should lengthof(something) return the number of bytes in the 'database 
encoding' or something else?
Bytes of course. Of the data stored, i.e. excluding the header byte
and encoded size (if any) from the file-format.
Basically the same as length() *except* for text values, resulting in
O(1) behavior. --DD


Please have mercy - my beautiful text-extracty queries will no longer work!

I'm OK with a second other function, perhaps called bytelength() that returns what you suggest, but length is mostly used in any text extracting or parsing along with with other functions like instr() and substr() etc. which all take character indexes based on positions of code-points and not of actual bytes.

Back in the day when all text was ANSI ASCII 8-byte Latin-English characters this was easy, but now it ain't.

That said, I thought that if you cast a string to BLOB and then query the length, like: SELECT length(CAST(firstname AS BLOB)) AS bytelen; You essentially get what you asked for, but I've never used it, so am not sure.




_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to