Forum OpenACS Q&A: Re: How can I make euc-kr(Korean) encoded .tcl and .adp work properly?

This sounds like the exact problem discussed at the beginning of Rob Mayoff's article:

http://dqd.com/~mayoff/encoding-doc.html

I would guess what's happening is that your .html files are being simply streamed out to the browswer by AOLserver without any conversion. If your version of AOLserver is configured to use euc-kr as the output charset, and that's the encoding of the .html file, then all is well. (You set OutputCharset to euc-kr in your Aolserver config file, right?)

When you use .tcl and .adp files, the files are being opened by AOLserver and read into a unicode space used by tcl internally, so a conversion occurs. The assumption of what type of file is being opened is key. If tcl thinks the file is unicode and it's not, you'll get garbage for all non-ASCII characters.

I believe the procedure you want to look at is template::util::read_file

You can add the line:

    fconfigure $fd -encoding <charset_name>

matching charset_name to the encoding of your files on disk. Be careful here: the charset names for tcl are different than the ones used by AOLserver... meaning you may have to use a different name than you used for OutputCharset.

Also check out these threads:

https://openacs.org/forums/message-view?message_id=52676  (has information on converting between tcl and Aolserver names for encodings)

https://openacs.org/forums/message-view?message_id=52676