Actually, nothing in the C or C++ world will "go past" the NULL byte since the 
very definition of a C string is a "bunch-o-bytes that are non-zero followed by 
one that is".

If you want to embed non UTF8 text you should be using a BLOB not TEXT.  Text 
means "an array of non-zero characters terminated by a zero byte" and a BLOB 
means a "bag-o-bytes" of a specific size.

Things meants to work on C "strings" should always stop at the zero terminator. 
 Failure to do so can lead to AHBL.

(Note, this applies to "wide" (as in word) and "fat" (as in double word) and 
obese (as in quad word) strings as well.  They are a sequence of 
words/double-words/quad-words/ten-words (whatever) that are non-zero followed 
by one that is zero -- and the narrow/wide/fat/obese string ends at the zeo 
value).

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of J Decker
>Sent: Thursday, 19 April, 2018 14:09
>To: SQLite mailing list
>Subject: Re: [sqlite] SQLite3 - Search on text field with \0 binary
>data
>
>are you testing this in the sqlite3 shell or in your own program?
>You should have no issue getting thisdata,
>
>sqlite3_column_text followed by sqlite3_column_bytes  (the byte count
>is
>set when the data is fetched in some format).
>
>without modification, you can either excape \0 with    '||char(0)||'
>...
>
>"My data \0with binary".
>"My data "||char(0)||" with binary".
>
>or use a parameter binding to get the value stored in the database.
>
>The row with a nul should be stored in the database; but the command
>line
>shell will not return the right values for selects; it will truncate
>that
>returned values at the \0.
>
>
>On Thu, Apr 19, 2018 at 5:27 AM, MARCHAND Loïc
><loic.march...@tagginfo.com>
>wrote:
>
>> I index a file in a SQLite DB.
>> I create my table with this:
>> CREATE TABLE Record (RecordID INTEGER,Data TEXT,PRIMARY KEY
>(RecordID))
>>
>> I read a file, and for each line I add a row on the table. Each
>line can
>> have binary data at end. It's not a problem for many chars, but \0
>char
>> make a problem.
>> If I have a line like this : "My data \0with binary".
>> When I try to get data after the \0 not worked (SELECT substr(Data,
>11, 5)
>> FROM Record return an empty string or SELECT substr(Data, 4, 10)
>FROM
>> Record return data)
>>
>> When I try to search a data (SELECT Data FROM Record WHERE Data
>LIKE
>> '%binar%') return 0 rows returned.
>>
>> How can I solve this problem ? I try to replace \0 by an other char
>> sequence, but it's not a good idea because can I have this sequence
>in my
>> file.
>> Thank you
>> Loïc
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



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

Reply via email to