On 13 Jan 2020, at 9:26am, Dominique Devienne <ddevie...@gmail.com> wrote:

> Which implies length(text_val) is O(N), while
> length(blob_val) is O(1),
> something I never quite realized.

For this reason, and others discussed downthread, some languages which store 
Unicode strings store the number of graphemes as well as its contents.  So 
functions which care about the … let's call it "width" … just retrieve that 
number rather than having to parse the string to figure out the length.

In a Unicode string 'length' can mean

1) octet count (number of 8-bit bytes used to store the string)
2) number of code points (basic unicode unit)
3) number of code units (how code points get arranged in UTF8, UTF16, etc., not 
as simple as it looks)
4) length in graphemes (space-using units)
5) length in glyphs (font-rendering units)

and probably others I've forgotten.  Not to mention that I simplified the 
definitions of the above and may have got them wrong.

An application centred around rendering text (e.g. vector graphics drawing 
apps) might have each piece of text stored with all five of those numbers, just 
to save it from having to constantly recalculate them.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to