Skip to content
Tcl Source Code History Of Ticket 5fca83d78c
Login

History Of Ticket 5fca83d78c

Artifacts Associated With Ticket 5fca83d78c

  1. Ticket change [d5a20a6c8f] (rid 228362) by bhaible on 2024-07-01 18:34:20:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      On a Linux/glibc system, I have two French locales:
      $ LC_ALL=fr_FR.UTF-8 locale charmap
      UTF-8
      $ LC_ALL=fr_FR.ISO-8859-1 locale charmap
      ISO-8859-1
      
      ('locale charmap' is the command-line equivalent of nl_langinfo(CODESET).)
      
      In Tcl, [encoding system] should be set to an equivalent value, otherwise
      strings with non-ASCII characters are printed incorrectly to standard output.
      
      This works in Tcl 8.6:
      
      $ LC_ALL=fr_FR.UTF-8 tclsh8.6
      % encoding system
      utf-8
      
      $ LC_ALL=fr_FR.ISO-8859-1 tclsh8.6
      % encoding system
      iso8859-1
      
      But it does not work for the ISO-8859-1 locale any more in Tcl 9.0 beta2:
      
      $ LC_ALL=fr_FR.UTF-8 tclsh9.0
      % encoding system
      utf-8
      
      $ LC_ALL=fr_FR.ISO-8859-1 tclsh9.0
      % encoding system
      utf-8
      
      I debugged it. nl_langinfo(CODESET) comes out as "ISO-8859-1".
      This string is lowercased, producing "iso-8859-1", and then a lookup in
      LocaleTable is done, in function SearchKnownEncodings. The table
      happens to have 174 elements, and the "iso-8859-1" is at index 80.
      Due to a logic bug in function SearchKnownEncodings, this index is not found.
      SearchKnownEncodings then returns NULL.
      
      The attached patch fixes the bug. The bug is present since 2005, but
      triggered on different encodings, because of the influence of the table
      length and the searched entry's index.
      
    5. foundin initialized to: "9.0b2"
    6. is_private initialized to: "0"
    7. login: "bhaible"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "2233330cf6146dcc3447bbdcc73be6c76b5b8e35"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "bhaible"
    14. subsystem initialized to: "38. Init - Library - Autoload"
    15. title initialized to: "[encoding system] is wrong in an ISO-8859-1 locale"
    16. type initialized to: "Patch"
  2. Add attachment "0001-unix-Fix-encoding-system-in-ISO-8859-1-locales.patch" [db549e97b7] (rid 228363) by bhaible on 2024-07-01 18:35:40.

  3. Ticket change [4ac915b2c8] (rid 228374) by jan.nijtmans on 2024-07-01 19:56:44:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2460493.33106749"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      Thanks for this report and the patch!
      
      Your explanation makes 100% sense! Following the code, I see what's happening, and why this wasn't noticed in Tcl 8.x. Many thanks!
      
      Fixed in all branches now. Will be part of Tcl 9.0b3
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"