Re: funny blobs
- From: "3rdshiftcoder" <go@xxxxxxxx>
- Date: Mon, 30 Jul 2007 01:14:53 -0400
here is my corrected code.
i was real close for a while and kept forgetting to add
the final fconfigure. once i added it it works perfect.
so cool i finally got this to work.
thanks for helping,
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}]
set myFile2 "c:/Tcl/demos/binWord.doc"
set tmpFile [open $myFile2 w+]
fconfigure $tmpFile -translation binary
puts -nonewline $tmpFile $binary_data
db3 close
close $myFP
close $tmpFile
.
- References:
- funny blobs
- From: 3rdshiftcoder
- funny blobs
- Prev by Date: Re: funny blobs
- Next by Date: Re: funny blobs
- Previous by thread: Re: funny blobs
- Next by thread: Quick way to convert Integers to Binary in TCL
- Index(es):