[sqlite] Possible error using length on UTF-8 characters

2016-02-18 Thread Glyn Jones
Of Richard Hipp Sent: 17 February 2016 15:11 To: SQLite mailing list Subject: Re: [sqlite] Possible error using length on UTF-8 characters On 2/17/16, Glyn Jones wrote: > My code behaves differently: > % package require sqlite3 > 3.8.11.1 > % sqlite3 db :memory: > % db eval {CREATE

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Stephan Beal
On Wed, Feb 17, 2016 at 2:59 PM, Glyn Jones wrote: > Agreed. > The problem is that "length(id)" returns double the number of UTF-8 > characters, rather than the actual number input to the field using "insert". > According to the docs, i does that only if you've stored the data as a BLOB, not

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Glyn Jones
ubject: Re: [sqlite] Possible error using length on UTF-8 characters On 2/17/16, Glyn Jones wrote: > I set the schema to TEXT, but that apparently makes no difference! > > I'm using the TCL interface: > > set id "???" > db eval {insert into users (id, name) values (:id, :name

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Stephan Beal
On Wed, Feb 17, 2016 at 2:36 PM, Glyn Jones wrote: > The field is TEXT: > > sqlite> .schema operators > CREATE TABLE operators ( > uid INTEGER PRIMARY KEY, > id TEXT UNIQUE NOT NULL CHECK(length(id) BETWEEN 1 AND 20), > name TEXT

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Stephan Beal
On Wed, Feb 17, 2016 at 11:53 AM, Glyn Jones wrote: > My database is configured with encoding "UTF-8". > I have a table with a constraint check for 20 characters on a column. This > mostly works, but sometimes has some strange behaviour. > > One character in particular has caused a problem. The

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Meinlschmidt Stefan
> No. I think you are confused about how UTF8 works. > > The hexadecimal shown above is a 6-character string as follows: > > "\u00c2\u00ac\u00c2\u00ac\u00c2\u00ac" > > You are wanting this three-character string: > > "\uc2ac\uc283\uc283" > > The hex encoding of the string you want

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Glyn Jones
Of Stephan Beal Sent: 17 February 2016 14:09 To: SQLite mailing list Subject: Re: [sqlite] Possible error using length on UTF-8 characters On Wed, Feb 17, 2016 at 2:59 PM, Glyn Jones wrote: > Agreed. > The problem is that "length(id)" returns double the number of UTF-8 > chara

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Glyn Jones
linglists.sqlite.org] On Behalf Of Meinlschmidt Stefan Sent: 17 February 2016 13:57 To: sqlite-users at mailinglists.sqlite.org Subject: Re: [sqlite] Possible error using length on UTF-8 characters > sqlite> select hex(id) from operators; > C382C2ACC382C2ACC382C2AC This is hex utf8 for "

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Meinlschmidt Stefan
> sqlite> select hex(id) from operators; > C382C2ACC382C2ACC382C2AC This is hex utf8 for "??", i.e. 3? 0xc2 0xac, which again is utf8 for "?" (0xac) S.M. -- Dipl.-Phys. (Univ) Stefan Meinlschmidt, Senior Software Engineer Am Wolfsmantel 46, 91058 Tennenlohe, Germany Tel: +49-8458-3332-531

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Glyn Jones
m: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Richard Hipp Sent: 17 February 2016 13:39 To: SQLite mailing list Subject: Re: [sqlite] Possible error using length on UTF-8 characters On 2/17/16, Glyn Jones wrote: > My database i

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Glyn Jones
The field is TEXT: sqlite> .schema operators CREATE TABLE operators ( uid INTEGER PRIMARY KEY, id TEXT UNIQUE NOT NULL CHECK(length(id) BETWEEN 1 AND 20), name TEXT CHECK(length(trim(name)) > 0) ); Glyn.

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Glyn Jones
My database is configured with encoding "UTF-8". I have a table with a constraint check for 20 characters on a column. This mostly works, but sometimes has some strange behaviour. One character in particular has caused a problem. The hex value is "C2AC" - the "NOT SIGN (U+00AC)". Hopefully the

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Richard Hipp
On 2/17/16, Glyn Jones wrote: > My code behaves differently: > % package require sqlite3 > 3.8.11.1 > % sqlite3 db :memory: > % db eval {CREATE TABLE users(id,name);} > % set id "???" > ??? > % db eval {insert into users (id, name) values (:id,:id)} > % db eval {select hex(id) from users} >

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Richard Hipp
On 2/17/16, Glyn Jones wrote: > I set the schema to TEXT, but that apparently makes no difference! > > I'm using the TCL interface: > > set id "???" > db eval {insert into users (id, name) values (:id, :name)} > When I run this script: sqlite3 db :memory: db eval {CREATE TABLE users(id,name);}

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Richard Hipp
On 2/17/16, Richard Hipp wrote: > On 2/17/16, Glyn Jones wrote: >> sqlite> select hex(id) from operators; >> C382C2ACC382C2ACC382C2AC >> >> This should show three characters of values "C2AC", and when I read from >> the >> DB and display on an HTML page I do see " ???" >> > > No. I think you

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Richard Hipp
On 2/17/16, Glyn Jones wrote: > sqlite> select hex(id) from operators; > C382C2ACC382C2ACC382C2AC > > This should show three characters of values "C2AC", and when I read from the > DB and display on an HTML page I do see " ???" > No. I think you are confused about how UTF8 works. The

[sqlite] Possible error using length on UTF-8 characters

2016-02-17 Thread Richard Hipp
On 2/17/16, Glyn Jones wrote: > My database is configured with encoding "UTF-8". > I have a table with a constraint check for 20 characters on a column. This > mostly works, but sometimes has some strange behaviour. > > One character in particular has caused a problem. The hex value is "C2AC" - >