[PD-cvs] SF.net SVN: pure-data: [9785] branches/pd-extended/v0-40/pd/src/t_tkcmd.c

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Sun May 11 21:44:46 CEST 2008


Revision: 9785
          http://pure-data.svn.sourceforge.net/pure-data/?rev=9785&view=rev
Author:   eighthave
Date:     2008-05-11 12:44:46 -0700 (Sun, 11 May 2008)

Log Message:
-----------
This fixes bug 1572290 on Windows, and should help on the other platforms too.
I need to test the others now.

The problem was that the Tcl internal character encoding was just being sent straight to the pd process without being converted to the current system encoding.  I added Tcl_UtfToExternalDString() as an easy way to convert from the Tcl encoding to the current system encoding and it seems to work fine now.

Modified Paths:
--------------
    branches/pd-extended/v0-40/pd/src/t_tkcmd.c

Modified: branches/pd-extended/v0-40/pd/src/t_tkcmd.c
===================================================================
--- branches/pd-extended/v0-40/pd/src/t_tkcmd.c	2008-05-11 18:13:10 UTC (rev 9784)
+++ branches/pd-extended/v0-40/pd/src/t_tkcmd.c	2008-05-11 19:44:46 UTC (rev 9785)
@@ -509,10 +509,14 @@
 
 static int pdCmd(ClientData cd, Tcl_Interp *interp, int argc,  char **argv)
 {
+    Tcl_DString dstring; /* used to convert the Tcl string to the OS encoding */
+    char *dstring_char;
     if (argc == 2)
     {
         int n = strlen(argv[1]);
-        if (send(sockfd, argv[1], n, 0) < n)
+        /* NULL as first arg means use the current system encoding */
+        dstring_char = Tcl_UtfToExternalDString(NULL, argv[1], -1, &dstring);
+        if (send(sockfd, dstring_char, n, 0) < n)
         {
             perror("stdout");
             tcl_mess("exit\n");
@@ -534,12 +538,15 @@
             if (i > 1) strcat(buf, " ");
             strcat(buf, argv[i]);
         }
-        if (send(sockfd, buf, strlen(buf), 0) < 0)
+        /* NULL as first arg means use the current system encoding */
+        dstring_char = Tcl_UtfToExternalDString(NULL, buf, -1, &dstring);
+        if (send(sockfd, dstring_char, strlen(dstring_char), 0) < 0)
         {
             perror("stdout");
             tcl_mess("exit\n");
         }
     }
+    Tcl_DStringFree(&dstring);
     return (TCL_OK);
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list