funny blobs
- From: "3rdshiftcoder" <go@xxxxxxxx>
- Date: Sun, 29 Jul 2007 23:45:27 -0400
hi -
i think from code snippets on the web i put a ms word doc in
a db table. if i encode i get printable ascii. if i decode i get
funny symbols.
how do you read the data in the db table if it comes out binary
decoded?
right now i think my last tk_messageBox is printing out
the ascii character for either decode or encode but that
doesnt tell me the characters that are typed into the word
ms doc file. in the doc file i may have typed
the words "funny blob test".
it seems you must be able to read the contents of that stored
file in the db table or it doesnt make much sense.
i read in fancy sqlite managers they even have the capability
to edit a blob. so that is proof to me that they can at least
read the data. changing it is another story....
thanks for any help,
jim
package require base64
set myFile c:/Tcl/bin/binWord.doc
# ---- open and read file ----
set myFP [ open $myFile r ]
fconfigure $myFP -translation binary
set {pure file} [ read $myFP ]
# ---- encode ----
#set {encoded file} [ ::base64::encode ${pure file} ]
package require sqlite3
sqlite db3 c:/Tcl/bin/db3
db3 eval "
CREATE TABLE blobs(
blob_id TEXT PRIMARY KEY,
blob BLOB
);"
sqlite db3 c:/Tcl/bin/db3
db3 eval "insert into blobs
(blob_id, blob)
values (1,'[::base64::encode ${pure file}]')"
set binary_data [base64::decode [db3 eval "
select blob from blobs where blob_id = 1"]]
tk_messageBox -message [::base64::encode ${pure file}]
binary scan [::base64::encode ${pure file}] "ccc" a b c
set c
tk_messageBox -message $b
db3 close
close $myFP
.
- Follow-Ups:
- Re: funny blobs
- From: 3rdshiftcoder
- Re: funny blobs
- From: slebetman@xxxxxxxxx
- Re: funny blobs
- Prev by Date: resizing JPEGs (with Img and photo image)
- Next by Date: Re: funny blobs
- Previous by thread: resizing JPEGs (with Img and photo image)
- Next by thread: Re: funny blobs
- Index(es):
Relevant Pages
|