Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a4d56887ebe7b1396ede425082566f6e73d419ff
Ticket: 1306162fffffffffffffffffffffffffffffffff
some args turned into garbages on cp932
User & Date: nobody on 2005-09-28 14:18:45
Changes

  1. icomment:
    Logged In: NO 
    
    Well, I think the problem is here.
    
    line 242- Tcl_Main function in generic/tclMain.c 
    ----------------------
    args = Tcl_Merge(argc-1, (CONST char **)argv+1);
    Tcl_ExternalToUtfDString(NULL, args, -1, &argString);
    Tcl_SetVar(interp, "argv", Tcl_DStringValue(&argString),
    TCL_GLOBAL_ONLY);
    
    
    Tcl_Merge function escape { and } in argv. so if a 2byte
    character has { or }, it will be escaped, and it makes garbage.
    I think First, args should be encoded to utf-8, Second we
    should make argv list.
    I don't know a lot about Tcl API, but I try to write correct
    code.
    It will be more clear than my poor english...
    
    ----------------------
    Tcl_Obj *listobj = Tcl_NewListObj(0, NULL);
    
    for (i=1; i<argc; i++) {
        Tcl_Obj *argobj = NULL;
        Tcl_ExternalToUtfDString(NULL, argv[i], -1, &argString);
        argobj = Tcl_NewStringObj(Tcl_DStringValue(&argString), -1);
        Tcl_ListObjAppendElement(interp, listobj, argobj);
    }
    Tcl_SetVar2Ex(interp, "argv", NULL, listobj, TCL_GLOBAL_ONLY);
    Tcl_DStringFree(&argString);
    
    
    thanks
    
    
  2. login: "nobody"
  3. mimetype: "text/plain"
  4. username: "nobody"