Skip to content
Tcl Source Code View Ticket
Login

View Ticket

clock format double utf-8 conversion

Closed / Fixed624408ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-10-17 02:05:59
I noticed the following bug with clock format on win2k
german, SP2.


Timezone is:
Westeuropäische Sommerzeit

Now look at this:
tclsh84.exe
% clock format [clock seconds]
Thu Oct 17 04:00:14 Westeuropäische Sommerzeit 2002

This is wrong.
% clock format [clock seconds] -format "%Z"
Westeuropäische Sommerzeit

% encoding convertfrom utf-8 [clock format [clock
seconds] -format "%Z"]]
Westeuropäische Sommerzeit

% encoding system
cp1252

So the timezone string gets converted to utf-8 twice,
which is wrong. 

I suspect the combination of:
generic\tclClock.c line 370
and
win/tclWinTime.c line 473 / 485
as the source of trouble.
nobodyplain2003-05-14 18:32:33
Logged In: NO 

[RS] Same problem on French Windows, as reported by 
David Zolli in the chat:
clock format [clock second] == Wed May 14 13:20:24 Paris, 
Madrid (heure d'été) 2003
mic42plain2003-05-14 22:55:32
Logged In: YES 
user_id=302287

Possible Patch (could only check on Win2k):
Not best style but FormatClock is litered with #ifdef's anyway.

in tclClock.c/end of FormatClock:
    /*
     * Convert the time to UTF from external encoding [Bug:
3345]
     */
#if !defined(WIN32)
    Tcl_DStringInit(&uniBuffer);
    Tcl_ExternalToUtfDString(NULL, buffer.string, -1,
&uniBuffer);

    Tcl_SetStringObj(Tcl_GetObjResult(interp),
uniBuffer.string, -1);

    Tcl_DStringFree(&uniBuffer);
#else
    /*
     * No need for a conversion, just keep as it is.
     */
    Tcl_SetStringObj(Tcl_GetObjResult(interp),
buffer.string, -1);
#endif
    Tcl_DStringFree(&buffer);
    return TCL_OK;
kennykbplain2003-05-19 02:50:21
Logged In: YES 
user_id=99768

Modified TclpStrftime to return UTF-8 results everywhere; this
seemed more sensible than introducing yet another platform
specific test.
Log in (anonymous is fine) to add a comment.