On Jul 17, 2008, at 10:47 AM, Nolan Darilek wrote: > Hello. I'm trying to add BLOB support to a Ruby interface to > SQLite3 and > am running into an issue. I've created a column of type BLOB and am > writing ruby strings of binary data, but it seems like sqlite might be > null-terminating these strings. Specifically, when I check the > length of > the string in my program, it is 25. When it's written to the database > and read back, though, it's 2. Character 3 is a null. > > In looking at the type support documentation, it would appear that I'm > supposed to use the X"ABCD" notation for entering BLOB literals. Could > this be why my blobs are being null-terminated, since it looks as > if the > problem isn't in ruby? If so, Can anyone explain what is meant by > X"ABCD" notation? Is this a string in the form 'X"mybinaryliteral"'? I > tried that from the command line, and the string is entered as it > appears. Is it a regular string with an X before it? I also tried this > and X was an unrecognized token.
It's a hexadecimal representation of a blob of data. The literal X'ABCD' is a blob of length 2 bytes. The first byte is 0xAB, the second is 0xCD. If possible, it is easier to use sqlite3_bind_blob() (or whatever the ruby equivalent is) to insert binary data. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users