|
2024-08-30
| ||
| 15:45 | Merge [0fa0310528423735]: Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale. check-in: 5668898199 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2024-07-01
| ||
| 19:56 | • Closed ticket [5fca83d78c]: encoding system is wrong in an ISO-8859-1 locale</... artifact: 4ac915b2c8 user: jan.nijtmans | |
| 19:39 | Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale check-in: 0fa0310528 user: jan.nijtmans tags: trunk, main | |
| 19:29 | Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale check-in: 813a60d2b9 user: jan.nijtmans tags: core-8-branch | |
| 19:22 | Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale check-in: cb29f3c08d user: jan.nijtmans tags: core-8-6-branch | |
| 18:35 | • Add attachment [/artifact/8b2c99c16517b67d|0001-unix-Fix-encoding-system-in-ISO-8859-1-locales.patch... artifact: db549e97b7 user: bhaible | |
| 18:34 | • New ticket [5fca83d78c] encoding system is wrong in an ISO-8859-1 locale. artifact: d5a20a6c8f user: bhaible | |
[encoding system] is wrong in an ISO-8859-1 locale
Closed / Fixed5fca83d78cf37b70d3e958897b542f985f2ce56aCreated 2 years agoUpdated 2 years ago
Descriptionplain2024-07-01 18:34:20
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.
Referenced by4
5668898199Merge [0fa0310528423735]: Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale. check-in2024-08-30 15:45:400fa0310528Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale check-in2024-07-01 19:39:46813a60d2b9Fix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale check-in2024-07-01 19:29:35cb29f3c08dFix [5fca83d78c]: [encoding system] is wrong in an ISO-8859-1 locale check-in2024-07-01 19:22:00
jan.nijtmanswiki2024-07-01 19:56:44
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
Log in (anonymous is fine) to add a comment.