On Fri, Apr 15, 2016 at 3:56 PM, Cecil Westerhof <cldwesterhof at gmail.com> wrote:
> 2016-04-15 8:45 GMT+02:00 Dominique Devienne <ddevienne at gmail.com>: > > On Thu, Apr 14, 2016 at 9:30 PM, Cecil Westerhof <cldwesterhof at > > gmail.com>> > wrote: > > ?Is there a way to convert a hex string to a blob? I did not find it yet.? > I didn't find one either (see below), beside formatting a SQL statement with a blob literal, kinda like sprintf(..., "x'%s'", hex_string), which is hardly an option. I'm surprised there's no built-in function or SQL way to do it. I suspect there is, and I'm missing something. Hopefully someone will chime in. Perhaps a CTE could do it. I'd reach for C/C++ and custom functions for such things. (I'd use a UDF for the printing part as well, I suspect it's faster that way, but didn't measure it). C:\Users\DDevienne>sqlite3 SQLite version 3.10.2 2016-01-20 15:27:19 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> sqlite> select typeof(x'ab'); blob sqlite> select typeof('ab'); text sqlite> select typeof(cast('ab' as blob)); blob sqlite> select hex(x'ab'); AB sqlite> select hex(cast('ab' as blob)); 6162 sqlite>