From Newsgroup: comp.lang.tcl
* rene <
user4652@newsgrouper.org.invalid>
| Rich <
rich@example.invalid> posted:
| > As you didn't post a complete working code segment that messes the PNG
| > up, we have nothing to go on to suggest which possible alternative may
| > be the most probable.
| >
| Here is a working script. The problem is the same.
| ::sqlite3 ::d :memory:
| set f [::open t.png r]
| ::fconfigure $f -translation binary
| set c1 [::read $f]
| ::close $f
| ::d eval {create table t1(i integer, c BLOB);}
| ::d eval {insert into t1 values(1,$c1)}
| set c2 [::d eval {select c from t1 where i=1}]
I can confirm that the contents in the DB is altered after reading it
back:
# read from t.png
% foreach c [split [string range $c1 0 10] ""] { puts [format %02x [scan $c %c]] }
89
50
4e
47
0d
0a
1a
0a
00
00
00
# read back from sqlite
% foreach c [split [string range $c2 0 10] ""] { puts [format %02x [scan $c %c]] }
89
50
4e
47
5c
72
5c
6e
1a
5c
6e
%
I.e. the binary \r\n (0x0d 0x0a) in c1 has been changed into
literal \ r \ n (0x5c 0x72 0x5c 0x6e) in c2.
I don't know nothing about blobs in sqlite, and whether the above method
is the correct way to handle binary content in the database, but if it
is, something somewhere in the line or processing translates the binary
content into the ASCII representation.
R'
--- Synchronet 3.21f-Linux NewsLink 1.2