TIP #106: ADD ENCODING ABILITIES TO THE [DDE] COMMAND ======================================================= Version: $Revision: 1.14 $ Author: Harald Oehlmann State: Final Type: Project Tcl-Version: 8.6 Vote: Done Created: Tuesday, 13 August 2002 URL: https://tip.tcl-lang.org106.html Post-History: ------------------------------------------------------------------------- ABSTRACT ========== When using Windows DDE communication with non-Tcl programs, the encoding of the exchanged strings is mostly needed to be the system encoding. Selection of this behaviour should be possible with in the *dde* command should be done by a parameter. SPECIFICATION =============== Extend the *dde* commands taking a data argument by the switch *-binary*: *dde execute* ?*-async*? ?*-binary*? /service topic data/ *dde poke* ?*-binary*? /service topic item data/ The argument /data/ is taken as a binary string if the *-binary* switch is given. Otherwise, it is interpreted as utf-8. Examples: dde execute -binary CS CS [encoding convertto [encoding system] Äpfel]\0 dde poke -binary CS CS I [encoding convertto [encoding system] Äpfel]\0 RATIONALE =========== The communication with DDE with external programs uses the format clipboard /CF_TEXT/ and the sent text should be coded in the system encoding (/cp1252/ in my locale). Most people who use DDE to communicate with, for example, Excel use the fact that what Excel expects (/cp1252/) and what Tcl actually sends (/utf-8/) is identical for 7-bit values and they don't use 8-bit values. Unfortunately, characters used in languages like German, French, etc., are located over this limit and thus are not transferable. Peter Hardie addressed this point on 2000-10-26 in the Tcl Feature Request at SourceForge (#219185: "dde only handles UTF-8 data (-binary patch available)" []). His proposal was to add a *-binary* option. This is a reasonable solution, because any encoding including the system encoding may be used as shown in the upper example. REFERENCE IMPLEMENTATION ========================== See the /tip-106-impl/ branch in Tcl's fossil repository []. REJECTED ALTERNATIVES ======================= I proposed to use a switch ?*-encoding* /encoding/? which would avoid the preparation of an encoded string by *encoding convertto*. DDE is so little used at those days so a minimal support is sufficient. The *dde request* subcommand already has a parameter /-binary/. It is more logical to extend this to the other commands. COPYRIGHT =========== This document has been placed in the public domain ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows