Re: [sqlite] Help with sqlite3_value_text

2019-04-16 Thread x
t;-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of x >Sent: Monday, 15 April, 2019 04:08 >To: SQLite mailing list >Subject: Re: [sqlite] Help with sqlite3_value_text > >>As long as you use _value_bytes after

Re: [sqlite] Help with sqlite3_value_text

2019-04-15 Thread Simon Slavin
I don't know about any of this, but it seems that someone needs to write a 'Unicode' (or 'Multibyte charaacters') page for the SQLite documentation. Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Help with sqlite3_value_text

2019-04-15 Thread Keith Medcalf
sage- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of x >Sent: Monday, 15 April, 2019 04:08 >To: SQLite mailing list >Subject: Re: [sqlite] Help with sqlite3_value_text > >>As long as you use _value_bytes after _text you'r

Re: [sqlite] Help with sqlite3_value_text

2019-04-15 Thread Clemens Ladisch
x wrote: >> As long as you use _value_bytes after _text you're fine... so if any >> conversion did take place the value will be right of the last returned >> string type. > > Could you explain that to me? I’m not sure why any conversion takes place > and, on reading the text below, I would’ve

Re: [sqlite] Help with sqlite3_value_text

2019-04-15 Thread x
>As long as you use _value_bytes after _text you're fine... so if any >conversion did take place the value will be right of the last returned >string type. JD, Could you explain that to me? I’m not sure why any conversion takes place and, on reading the text below, I would’ve thought it would be

Re: [sqlite] Help with sqlite3_value_text

2019-04-14 Thread J Decker
On Sun, Apr 14, 2019 at 5:40 AM x wrote: > On second thoughts JD, can’t use strlen or sqlite3_value_bytes in case > values(1) contains more than a single unicode character. This looks OK. > > Bytes are what you need though; it doesn't matter how big the buffer is, as long as you have all of it.

Re: [sqlite] Help with sqlite3_value_text

2019-04-14 Thread x
On second thoughts JD, can’t use strlen or sqlite3_value_bytes in case values(1) contains more than a single unicode character. This looks OK. # define CHARLEN(x) !(x & 128) ? 1 : (x & 16 ? 4 : (x & 32 ? 3 : 2)) char *c = (char *)sqlite3_value_text(values[0]); char *Sep = (char

Re: [sqlite] Help with sqlite3_value_text

2019-04-14 Thread x
From: J Decker<mailto:d3c...@gmail.com> Sent: 13 April 2019 20:05 To: SQLite mailing list<mailto:sqlite-users@mailinglists.sqlite.org> Subject: Re: [sqlite] Help with sqlite3_value_text >> char *c = (char *)sqlite3_value_text(values[0]); >> char *Sep = (char *)sql

Re: [sqlite] Help with sqlite3_value_text

2019-04-13 Thread J Decker
> // at first byte of Sep > >c += NrBytes; > > } > > sqlite3_result_int(ctx, Count); > > > > ____ > From: sqlite-users on > behalf of Scott Robison > Sent: Friday, April 12, 2019 8:40:19 PM > To: SQLite mai

Re: [sqlite] Help with sqlite3_value_text

2019-04-13 Thread x
emcmp(c, Sep, NrBytes) == 0) Count++; // at first byte of Sep c += NrBytes; } sqlite3_result_int(ctx, Count); From: sqlite-users on behalf of Scott Robison Sent: Friday, April 12, 2019 8:40:19 PM To: SQLite mailing list Subject: Re: [sqlite] Help with

Re: [sqlite] Help with sqlite3_value_text

2019-04-13 Thread x
Thanks for all the help. Things are much clearer now. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Warren Young
On Apr 12, 2019, at 1:06 PM, Keith Medcalf wrote: > > Actually you would have to convert the strings to UCS-4. UTF-32 is the new name of that standard: https://en.wikipedia.org/wiki/UTF-32#History > UTF-16 is a variable-length encoding. Only if you’re outside the BMP, which is why I

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Leland Helgerson
-Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Scott Robison Sent: Friday, April 12, 2019 2:40 PM To: SQLite mailing list Subject: Re: [sqlite] Help with sqlite3_value_text On Fri, Apr 12, 2019, 1:06 PM Keith Medcalf wrote

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Scott Robison
On Fri, Apr 12, 2019, 1:06 PM Keith Medcalf wrote: > > Actually you would have to convert the strings to UCS-4. UTF-16 is a > variable-length encoding. An actual "unicode character" is (at this > present moment in time, though perhaps not tomorrow) 4 bytes (64-bits). > That is some impressive

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Keith Medcalf
eaven says a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Warren Young >Sent: Friday, 12 April, 2019 09:45 >To: SQLite mailing list >Subject: Re: [sqlite] Help with sqlite3_v

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Richard Damon
> On Apr 12, 2019, at 12:58 PM, x wrote: > > I’ve been asking myself if I could have done the above more efficiently as > sqlite’s converting the original string then I’m converting it and copying > it. While thinking about that I started to wonder how c++ handled utf8/16. > E.g. To access

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread x
Thanks for the replies. There’s plenty for me to look at there. I’ve been in poor health the last 5 years and after almost a year’s break I’m trying to get back into sqlite to preserve my sanity. I’m so rusty my opening post is riddled with errors. I’ve just realised that, before my break, I

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Warren Young
On Apr 12, 2019, at 8:51 AM, x wrote: > > How do I do the same thing if the string param is a utf-8 or utf-16 string > and the SearchChar is a Unicode character? Convert the characters to 32-bit wide characters first, then iterate over the array of uint32_t or similar. One method is shown by

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Shawn Wagner
Welcome to the wonderful world of multibyte encodings, and Unicode in particular. Unless you're looking for an ASCII character, you're looking for a substring, not a character. And you're really looking for what's called a codepoint (The entire concept of character gets kind of fuzzy with

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread J Decker
http://utf8everywhere.org/ On Fri, Apr 12, 2019 at 7:51 AM x wrote: > I’m still confused by utf strings. For simplicity, suppose I set up an > sqlite function that takes a single string parameter and I want to scan the > string to count the number of occurrences of a certain character . If I >

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Dominique Devienne
On Fri, Apr 12, 2019 at 4:51 PM x wrote: > I’m still confused by utf strings. [... I want to scan the string to > count the number of occurrences of a certain character. [...] > How do I do the same thing if the string param is a utf-8 or utf-16 string > and the SearchChar is a Unicode

Re: [sqlite] Help with sqlite3_value_text

2019-04-12 Thread Igor Tandetnik
On 4/12/2019 10:51 AM, x wrote: I’m still confused by utf strings. For simplicity, suppose I set up an sqlite function that takes a single string parameter and I want to scan the string to count the number of occurrences of a certain character . If I knew the string was made up entirely of

[sqlite] Help with sqlite3_value_text

2019-04-12 Thread x
I’m still confused by utf strings. For simplicity, suppose I set up an sqlite function that takes a single string parameter and I want to scan the string to count the number of occurrences of a certain character . If I knew the string was made up entirely of ascii chars I’d do this char *c =