Forum OpenACS Q&A: Response to howto run 3.2.5 with European characters on nsd8x

I've been running a website with OpenACS 3.2.4 on nsd8x with iso 8859-2 for some time now. It is not the same encoding you are going to use but ... why not give it a try replacing 8859-2 with 8859-1 along the way?

Database setup: the OACS database in PostgreSQL was created with

 createdb -E LATIN2 yourdb 
so it stores stuff with single-byte encoding internally. Since tcl8x handles strings in unicode, I added this to /etc/profile:
So, the string conversion between PostgreSQL and Aolserver is done smoothly by the first one.

Now, to get iso 8859-2 output from Aolserver, you need to add a few lines to your nsd.tcl:

 ns_section "ns/parameters"
        ns_param   OutputCharset iso-8859-2
        ns_param   UrlCharset iso-8859-2
        ns_param   HttpOpenCharset iso-8859-2

 ns_section "ns/mimetypes"
    ns_param ".html" "text/html; charset=iso-8859-2"
    ns_param ".txt" "text/plain; charset=iso-8859-2"
    ns_param ".adp" "text/plain; charset=iso-8859-2"

 encoding system iso8859-2
at the end of the file. That basically does the trick for output. To make input work, you should edit form.tcl (from aolserver/modules/tcl), find this line:
 ns_set put $form $name $value 
and replace it with
 ns_set put $form $name [encoding convertfrom iso8859-2 $value]

Well, that is it, more or less. Two issues remain: getting the right charset in outgoing emails generated by OpenACS and correct ADP parsing. I am not sure how I solved these - IIRC the trick with ADP is to use another parser (from the two available) if you do not get good results from the start. With email - you need to modify sendmail.tcl and add to headers three lines describing the charset, in my case it is:

MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: 8bit

As for my setup, I am running Aolserver 3.2ad12 and PostgreSQL 7.1.3 (configured with --enable-unicode-conversion --enable-locale --enable-multibyte=UNICODE)

David, let me know if that works for you. If it does, I will look further into my code - I remember there was some additional tweaking needed to make OACS ADP templates output correct charset as well.