Re: Problem with freewrap and encoding (please just give it a try)
From: Dennis LaBelle (labelled_at_nycap.rr.com)
Date: 10/19/04
- Next message: Donald Arseneau: "Re: Sending CTRL+C in script to TCL shell"
- Previous message: Andrea Bonamini: "Sending CTRL+C in script to TCL shell"
- In reply to: Dennis LaBelle: "Re: Problem with freewrap and encoding (please just give it a try)"
- Next in thread: Victor Wagner: "Re: Problem with freewrap and encoding (please just give it a try)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 19 Oct 2004 00:16:22 GMT
Dennis LaBelle wrote:
> Stefano wrote:
>
>> Hi,
>> I guess this is my last resort. If no one from this group can answer
>> my question I guess I'll have to give up with freewrap. Even if I have
>> to admit that this is the only problem I had with it. But I usually
>> handle documents written with all kind of european characters, and
>> this seems to be a problem for freewrap version 5.61
>> (http://freewrap.sourceforge.net). I don't know if older versions are
>> bug free, but I don't know how to use encodings with older versions. I
>> found a comment of Dennis Labelle (freewrap's author) from 2002 on
>> this news group, but now the howto file of freewrap has changed as for
>> encodings, so I don't know how I could apply that suggestion.
>>
>> I would like to know if other people can replicate the "bug" I found,
>> or if this is just a problem of my PC configuration.
>>
>> I wrote a simple routine to get rid of special characters embedded in
>> an ASP file. This is the routine:
>>
>> ##### routine STARTS here
>> set autoweb(filename) {scheda0-orig.asp}
>> set autoweb(filenameout) {scheda0-out.asp}
>>
>> set fileId [open $autoweb(filename) "r"]
>> set htmlcontent [read $fileId]
>> close $fileId
>>
>> # creates string map array
>> set cmap {}
>> for {set i 161} {$i < 256} {incr i} {
>> lappend cmap [format "%c" $i] "&#$i;"
>> }
>>
>> # convert special characters to HTML codes
>> set htmlcontent [string map $cmap $htmlcontent]
>>
>> # clean ASP code from html document
>> regsub -all {<%.*%>} $htmlcontent {} htmlcontent
>>
>> # writes document back to local file
>> set parFileId [open $autoweb(filenameout) w]
>> puts $parFileId "${htmlcontent}"
>> close $parFileId
>>
>> exit
>> ##### routine ENDS here
>>
>> When I run this routine in Windows (windows 2000, english version)
>> just doubleclicking on the tcl file, everything works fine. I use Tcl
>> version 8.4.6. Instead, if I compile with freewrap 5.61, the output
>> file will be still readable but will contain some evident garbage
>> characters. I created a simplified version of my ASP file. I verified
>> that copying and pasting the following code does exactly reproduce the
>> problem:
>>
>> <html>
>> <head>
>> </head>
>> <body>
>> <h1>Progetto n°</h1>
>> </body>
>> </html>
>
>
> OK, exactly what do you mean by "copying and pasting the following code"?
> Those last few lines don't look like any special ASP stuff to me.
>
> And how does "copying and pasting" simulate the problems with some
> computer code?
>
If the local system encoding of the machine on which your program might run
is not suitable for your task, simply change the system encoding with a
line of code such as:
encoding system /tcl/encoding/iso8859-1
Contrary to what Victor Wagner says, freeWrap 5.61 contains all the encoding
files distributed with the normal TCL/TK package. They are accessible as
long as you use a full path when your code refers to them. They can be
found in the virtual file system directory /tcl/encoding. These files can
be listed using the command:
zvfs::list /tcl/encoding/*
I believe that adding the line with the encoding command above to your code
produces your desired result.
##### routine STARTS here
encoding system /tcl/encoding/iso8859-1
set autoweb(filename) {scheda0-orig.asp}
set autoweb(filenameout) {scheda0-out.asp}
set fileId [open $autoweb(filename) "r"]
set htmlcontent [read $fileId]
close $fileId
# creates string map array
set cmap {}
for {set i 161} {$i < 256} {incr i} {
lappend cmap [format "%c" $i] "&#$i;"
}
# convert special characters to HTML codes
set htmlcontent [string map $cmap $htmlcontent]
# clean ASP code from html document
regsub -all {<%.*%>} $htmlcontent {} htmlcontent
# writes document back to local file
set parFileId [open $autoweb(filenameout) w]
puts $parFileId "${htmlcontent}"
close $parFileId
exit
##### routine ENDS here
- Next message: Donald Arseneau: "Re: Sending CTRL+C in script to TCL shell"
- Previous message: Andrea Bonamini: "Sending CTRL+C in script to TCL shell"
- In reply to: Dennis LaBelle: "Re: Problem with freewrap and encoding (please just give it a try)"
- Next in thread: Victor Wagner: "Re: Problem with freewrap and encoding (please just give it a try)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|