On Wed, Feb 17, 2016 at 11:53 AM, Glyn Jones <glynj at bsquare.com> 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"
> - the "NOT SIGN (U+00AC)".
> Hopefully the character will appear between the quotes "?".
>
> When I insert this character into the table, it will only allow ten
> characters to be input.
>
> If I do "select length(name) from myTable;" the result shows that each of
> the "C2AC" characters  is counted as two characters.
>
> I noticed that "C2" is a valid ANSI character, as is "AC", so wonder if
> the length() function is not dealing correctly with the range from
> 0x80-0xff.
>

Is your field TEXT or BLOB? The docs say they behave differently:

https://www.sqlite.org/lang_corefunc.html

For a string value X, the length(X) function returns the number of
characters (not bytes) in X prior to the first NUL character. Since SQLite
strings do not normally contain NUL characters, the length(X) function will
usually return the total number of characters in the string X. For a blob
value X, length(X) returns the number of bytes in the blob.



-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf

Reply via email to