Forum OpenACS Q&A: My I18N Patches

Collapse
10: My I18N Patches (response to 1)
Posted by Henry Minsky on
Hi,

Here's the story with the patches I made for ACS 3.2.5: There were two kinds of patches; some patches for AOLserver, and some patches for ACS.

1) All the code that needed to be patched into the AOLserver executable or tcl library was folded into the ad+13 release by Rob Mayoff.

They were basically just a patch to ns_getform to make sure that the POST (or GET) data was stored in "raw binary" and then to allow you to request the form data in a specific character set (i.e., if the user submitted a form encoded in Shift_JIS, I need to tell ns_getform to convert the form data from Shift_JIS into Unicode before it gives it to my application or to ad_page_contract, etc).

2) The patch also has Tcl code for patching ACS so that it explicitly does character set conversions in places such as were described above, where a .html or .tcl or .adp file is loaded from the filesystem into Tcl. In all these cases, you must specify what encoding conversion to use when the file is read into a Tcl string. Otherwise, the default system encoding will be used, and that may not be what you want (although usually the system encoding is ISO-8859-1, so I am a little confused by why people are having trouble with that encoding). Actually in some cases the .adp processor expects UTF8 by default, so that could confuse people.

Anyway, the bottom line is that the patches to AOLserver are no longer needed, if you have AOLserver v ad+13.

The patches for ACS are available here: http://www.ai.mit.edu/people/hqm/openacs/

The basic approach of the ACS patch is to set up the MIME type table for files that you want to serve to include an explicit character set, i.e.,

ns_section "ns/mimetypes"
        ns_param   default         "*/*"     ;# MIME type for unknown extension
        ns_param   noextension     "*/*"     ;# MIME type for missing extension
        #ns_param   ".xls"         "application/vnd.ms-excel''
        ns_param .html "text/html; charset=shift_jis"
        ns_param .tcl "text/html; charset=shift_jis"
        ns_param .adp "text/html; charset=shift_jis"

in your init file

Then, the patches are supposed to make ACS look up the MIME type for files when it is handling them in various places, and try to interpret the charset to the specified one (both when it loads the files from disk, and when it outputs them to the client browser).

But warning: these patches for ACS 3.2.5 are hardcoded for shift_jis is a bunch of places. The approach was to allow the whole site to work in a specific character set by default. The constant string "shift_jis" could be replaced by a function or global parameter variable if you want. But I was extremely lazy and left it hardcoded all over the place in the patches.