Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_Eval does not treat a command the same as in the console

Closed / Fixed218100ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:53:09
OriginalBugID: 1803 Bug
Version: 8.1b3
SubmitDate: '1999-04-14'
LastModified: '2000-04-03'
Severity: SER
Status: Closed
Submitter: pat
ChangedBy: hobbs
OS: Windows 95
Machine: X86
FixedDate: '2000-10-25'
ClosedDate: '2000-04-03'


Name:
Di Yu

Comments:
This is a very bad problem as it makes the compilation of programs
    containing Chinese words virtually impossible. I don't know why Tcl_Eval
    think the string is 5-bytes with the third one as Unicode \u04dd, and
    not 6-bytes as the console treat it. In fact, when I try to compile a
    program which contains "encoding convertfrom gb2212 ...", the generated
    executable can hardly do any correct converting.

ReproducibleScript:
#include <tcl.h>
    void main(int argc, char **argv)
    {
        Tcl_Interp *Interp=Tcl_CreateInterp();
        Tcl_Init(Interp);
        Tcl_Eval(Interp, "set s ÏÂ?Ìâ");
        Tcl_Eval(Interp, "for {set i 0} {$i<[string length $s]} {incr i}
    {set c [string index $s $i]; scan $c \"%c\" code; puts [format \"%x\"
    $code];}");
        Tcl_DeleteInterp(Interp);
        exit(1);
    }

ObservedBehavior:
The program, after compiled to an executable file(under Windows, using
    VC++5.0), gives the following result when executed:
    
    cf
    c2
    4bb
    cc
    e2

DesiredBehavior:
It should give:
    
    cf
    c2
    d2
    bb
    cc
    e2
    
    just as the same script would give when executed in the wish console.



There is slight confusion here, because the console has an
implicit encoding phase the that user is ignoring.  The user
wants to do Tcl_ExternalToUtfDString to have this evaluate
correctly, or include some other conversion step at the C
level, to make up for the lack of internal recoding that the
console does for us. 
-- 04/03/2000 hobbs
welch Closed ticket [218100ffff]. [History diff]2000-10-26 08:14:47
dgp Open ticket [218100ffff]. [History diff]2001-04-06 03:33:59
dgp Closed ticket [218100ffff]. [History diff]2001-04-06 03:34:43
Log in (anonymous is fine) to add a comment.