tcl-websh-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronnie Brunner <ronnie.brun...@netcetera.ch>
Subject Re: i18n problems in Websh (multibyte charsets)
Date Mon, 29 Aug 2005 21:34:41 GMT
Hi

I looked at your patch. As you already know, it does not rellay work
yet. But can you tell me, what this modification s for?

diff -ur tcl-websh.orig/src/generic/formdata.c
tcl-websh/src/generic/formdata.c
--- tcl-websh.orig/src/generic/formdata.c       Mon Aug 29 13:24:13
2005
+++ tcl-websh/src/generic/formdata.c    Mon Aug 29 13:30:19 2005
@@ -41,6 +41,7 @@
     int readToEnd = 0;
     int content_length = 0;
     Tcl_DString translation;
+    Tcl_DString encoding;

     channel = Web_GetChannelOrVarChannel(interp, channelName, &mode);
     if (channel == NULL) {
@@ -63,7 +64,9 @@
     }

     Tcl_DStringInit(&translation);
+    Tcl_DStringInit(&encoding);
     Tcl_GetChannelOption(interp, channel, "-translation",
     &translation);
+    Tcl_GetChannelOption(interp, channel, "-encoding", &encoding);
     Tcl_SetChannelOption(interp, channel, "-translation", "binary");

     /*
     ------------------------------------------------------------------------
@@ -88,7 +91,9 @@
            if (Tcl_GetIntFromObj(interp, len, &content_length) !=
	    TCL_OK) {

                Tcl_SetChannelOption(interp, channel, "-translation",
		Tcl_DStringValue(&translation));
+               Tcl_SetChannelOption(interp, channel, "-encoding",
Tcl_DStringValue(&encoding));
                Tcl_DStringFree(&translation);
+               Tcl_DStringFree(&encoding);
                /* unregister if was a varchannel */
                Web_UnregisterVarChannel(interp, channelName,
		channel);
                return TCL_ERROR;
@@ -122,7 +127,9 @@
            Tcl_DecrRefCount(formData);

            Tcl_SetChannelOption(interp, channel, "-translation",
	    Tcl_DStringValue(&translation));
+           Tcl_SetChannelOption(interp, channel, "-encoding",
Tcl_DStringValue(&encoding));
            Tcl_DStringFree(&translation);
+           Tcl_DStringFree(&encoding);
            /* unregister if was a varchannel */
            Web_UnregisterVarChannel(interp, channelName, channel);

@@ -131,7 +138,9 @@
     }

     Tcl_SetChannelOption(interp, channel, "-translation",
     Tcl_DStringValue(&translation));
+    Tcl_SetChannelOption(interp, channel, "-encoding",
Tcl_DStringValue(&encoding));
     Tcl_DStringFree(&translation);
+    Tcl_DStringFree(&encoding);
     /* unregister if was a varchannel */
     Web_UnregisterVarChannel(interp, channelName, channel);

As far as I can see, this doesn't do anything: it just saves the
encoding, then doesn't do anything with it and before returning sets
it to the value it's already set to. Did I miss something?

> Does websh get contents from apache server as unicode string,
> or binary string?

I'm not sure if I understand your question correctly: The strings are
always the same (binary?). The encoding is just how you interpret
it. If you talk about multipart formdata: you get the encoding within
the data, otherwise (www-form-urlencoded) is just a defined 8-bit
encoding (I would not know how multibyte character sets are posted in
that encoding.)

If you talk about scripts that are sourced from mod_websh, you have to
look at src/generic/webinterp.c: in readWebInterpCode() we basically
do the following:

Tcl_Obj *objPtr = Tcl_NewObj();
chan = Tcl_OpenFileChannel(interp, filename, "r", 0644);
Tcl_ReadChars(chan, objPtr, -1, 0);
Tcl_Close(interp, chan);
-> objPtr is the code object that is later eval'ed using Tcl_EvalObjEx

Hope that helps

Best regards
Ronnie
-----------------------------------------------------------------------
Ronnie Brunner                              ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich, phone +41 44 247 79 79 fax +41 44 247 70 75

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org


Mime
View raw message