• info hostname containing umlaut on Windows

    From Ralf Fassel@21:1/5 to All on Wed May 22 16:24:18 2024
    tcl 8.6.14 (self-compiled from source), Windows 11,
    hostname contains an Umlaut: foo-läptop (Umlaut-a)

    % wish8.6
    % info hostname
    foo-läptop
    % info hostname
    foo-läpt

    The second time, the hostname is encoded another time.

    Looking at the code for [info hostname] on Windows, it seems to me:

    - information is stored in global variable
    static ProcessGlobalValue hostName =
    {0, 0, NULL, NULL, InitializeHostName, NULL, NULL};
    (win/tclWinSock.c)

    - the first time the information is retrieved by
    TclGetProcessGlobalValue(), it is initialized by a
    call to InitializeHostName(), which sets the encoding of the
    information to utf-8 after retrieving it from windows and converting
    it to utf-8
    *encodingPtr = Tcl_GetEncoding(NULL, "utf-8");
    (win/tclWinSock.c)

    - the next time the information is retrieved by
    TclGetProcessGlobalValue(), it sees that the encoding is non-NULL and
    compares it to the system encoding, which on Windows is not utf-8, but
    (in my case) cp1252. So the information is converted again.

    TclGetProcessGlobalValue()
    ...
    if (pgvPtr->encoding) {
    Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);

    if (pgvPtr->encoding != current) {
    /*
    * The system encoding has changed since the global string value
    * was saved. Convert the global value to be based on the new
    * system encoding.
    */

    // !! wrong for [info hostname]


    Can someone comfirm this?

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Wed May 22 17:51:46 2024
    Am 22.05.2024 um 16:24 schrieb Ralf Fassel:
    tcl 8.6.14 (self-compiled from source), Windows 11,
    hostname contains an Umlaut: foo-läptop (Umlaut-a)

    % wish8.6
    % info hostname
    foo-läptop
    % info hostname
    foo-läpt

    The second time, the hostname is encoded another time.

    Looking at the code for [info hostname] on Windows, it seems to me:

    - information is stored in global variable
    static ProcessGlobalValue hostName =
    {0, 0, NULL, NULL, InitializeHostName, NULL, NULL};
    (win/tclWinSock.c)

    - the first time the information is retrieved by
    TclGetProcessGlobalValue(), it is initialized by a
    call to InitializeHostName(), which sets the encoding of the
    information to utf-8 after retrieving it from windows and converting
    it to utf-8
    *encodingPtr = Tcl_GetEncoding(NULL, "utf-8");
    (win/tclWinSock.c)

    - the next time the information is retrieved by
    TclGetProcessGlobalValue(), it sees that the encoding is non-NULL and
    compares it to the system encoding, which on Windows is not utf-8, but
    (in my case) cp1252. So the information is converted again.

    TclGetProcessGlobalValue()
    ...
    if (pgvPtr->encoding) {
    Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);

    if (pgvPtr->encoding != current) {
    /*
    * The system encoding has changed since the global string value
    * was saved. Convert the global value to be based on the new
    * system encoding.
    */

    // !! wrong for [info hostname]


    Can someone comfirm this?

    R'


    Great observation. File a bug to discuss there.

    Thanks,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Wed May 22 18:33:17 2024
    * Harald Oehlmann <[email protected]>
    | Am 22.05.2024 um 16:24 schrieb Ralf Fassel:
    | > tcl 8.6.14 (self-compiled from source), Windows 11,
    | > hostname contains an Umlaut: foo-läptop (Umlaut-a)
    | > % wish8.6
    | > % info hostname
    | > foo-läptop
    | > % info hostname
    | > foo-läpt
    | > The second time, the hostname is encoded another time.
    --<snip-snip>--


    | Great observation. File a bug to discuss there.

    [x] done. https://core.tcl-lang.org/tcl/tktview/3fc3287497a7e281b96661f883c20e0e74a0fca7

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)