Hey Federico,
I just finished getting full unicode support on Pd-extended 0.43.4 and ran into a bizarre problem. It turns out that when tclpd is loaded by default, Pd freaks out on some Portugeuse text like "modulação". Replace the ç and ã with c and a, and the problem goes away. Or stop loading tclpd at startup and the problem goes away. I attached the patch in question. This only happens on GNU/Linux, Windows and Mac OS X are unaffected.
I tried looking around the code, and using strace to follow the function calls, but I didn't see anything. I'd like to be able to include tclpd by default in Pd-extended, but this is a show stopper.
.hc
IOhannes provided the key insight into the source of the problem, it seems there is a clash of character encodings between pd and tclpd. This kludge makes it work on my machine:
hans@palatschinken tclpd $ svn diff Index: tclpd.c =================================================================== --- tclpd.c (revision 16755) +++ tclpd.c (working copy) @@ -14,13 +14,21 @@ /* verbose(-1) post to the pd window at level 3 */ verbose(-1, "tclpd loader v" TCLPD_VERSION);
+/* kludge to work around tclpd messing up the loading of UTF-8 patches. This + * should really be solved correctly, its probably caused by the + * locale/encoding not being setup correctly, perhaps in pd itself */ +#if defined __gnu_linux__ || defined __GNU__ || defined __FreeBSD_kernel__ + char *lang = getenv("LANG"); + setenv("LANG", "C", 1); +#endif proxyinlet_setup();
tclpd_interp = Tcl_CreateInterp(); Tcl_Init(tclpd_interp); Tclpd_SafeInit(tclpd_interp); +#if defined __gnu_linux__ || defined __GNU__ || defined __FreeBSD_kernel__ + setenv("LANG", lang, 1); +#endif
Tcl_Eval(tclpd_interp, "package provide Tclpd " TCLPD_VERSION);
But it would be much better to get to the bottom of this problem, so that we don't have to use this kludge again and again. One possibility is that Pd itself does not have its encodings setup properly. I haven't looked into that. I did mess around with Tcl's C functions for setting the encoding, but it didn't seem to change anything: http://pure-data.svn.sourceforge.net/viewvc/pure-data/branches/pd-extended/0...
This is what I was doing to test it:
$ LANG=en_US pd-extended (always worked fine) $ LANG=en_US.UTF-8 pd-extended (always caused the freak-outs on unicode chars)
.hc
On 12/17/2012 08:56 PM, Hans-Christoph Steiner wrote:
Hey Federico,
I just finished getting full unicode support on Pd-extended 0.43.4 and ran into a bizarre problem. It turns out that when tclpd is loaded by default, Pd freaks out on some Portugeuse text like "modulação". Replace the ç and ã with c and a, and the problem goes away. Or stop loading tclpd at startup and the problem goes away. I attached the patch in question. This only happens on GNU/Linux, Windows and Mac OS X are unaffected.
I tried looking around the code, and using strace to follow the function calls, but I didn't see anything. I'd like to be able to include tclpd by default in Pd-extended, but this is a show stopper.
.hc