|
2023-04-22
| ||
| 08:05 | • New ticket [203792a48c] Avoid signed integer overflow in Utf32ToUtfProc(). artifact: 48bb1e2e08 user: chrstphrchvz | |
|
2023-03-22
| ||
| 12:25 | Merge trunk: Final part of [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. Problem was in tes... check-in: f763b2396e user: pooryorick tags: unchained | |
|
2023-02-16
| ||
| 21:31 | • Closed ticket [10c2c17c32]: UTF-LE32 encoder mapping of surrogates plus 7 ot... artifact: e1db249ccd user: jan.nijtmans | |
| 21:29 | Final part of [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. Problem was in testcase, not in ... check-in: fc029613d5 user: jan.nijtmans tags: trunk, main | |
|
2023-02-15
| ||
| 07:30 | • Ticket [10c2c17c32] UTF-LE32 encoder mapping of surrogates status still Open... artifact: bcd3cf0427 user: jan.nijtmans | |
| 07:21 | Ticket [10c2c17c32] follow-up. One output char too much with -failindex. check-in: 6349e0c2e1 user: jan.nijtmans tags: core-8-branch | |
| 05:38 | • Ticket [10c2c17c32] UTF-LE32 encoder mapping of surrogates status still Open... artifact: b446e51830 user: apnadkarni | |
|
2023-02-13
| ||
| 10:14 | • Open ticket [10c2c17c32]. artifact: 12b9a533fe user: jan.nijtmans | |
| 08:40 | • Closed ticket [10c2c17c32]. artifact: 72f8cf14bf user: jan.nijtmans | |
| 08:39 | Fix for [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. With testcases (both for utf-32 and ut... check-in: 26aadbbd1f user: jan.nijtmans tags: core-8-branch | |
|
2023-02-09
| ||
| 07:57 | • Ticket [10c2c17c32] UTF-LE32 encoder mapping of surrogates status still Open... artifact: 3624f5267d user: jan.nijtmans | |
|
2023-02-08
| ||
| 15:38 | • Ticket [10c2c17c32]: 3 changes artifact: 0642977d2a user: apnadkarni | |
|
2023-02-07
| ||
| 15:02 | • Ticket [10c2c17c32]: 3 changes artifact: 6cdb9ac9d5 user: jan.nijtmans | |
| 07:38 | • Ticket [10c2c17c32]: 3 changes artifact: 43348994a9 user: apnadkarni | |
|
2023-02-06
| ||
| 22:43 | Proposed fix for [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. TODO: testcase check-in: 0bb13aadb6 user: jan.nijtmans tags: bug-10c2c17c32 | |
| 21:18 | • Ticket [10c2c17c32] UTF-LE32 encoder mapping of surrogates status still Open... artifact: f264613885 user: jan.nijtmans | |
| 17:02 | • Ticket [10c2c17c32]: 3 changes artifact: 9d8934b42d user: apnadkarni | |
| 17:01 | • New ticket [10c2c17c32]. artifact: 74030b1761 user: apnadkarni | |
UTF-LE32 encoder mapping of surrogates
While beefing up test cases for encoders, the following seems suspect to me.
% proc codepoints {s} {join [lmap c [split $s ""] {
string cat U+ [format %.8X [scan $c %c]]}]
}
% codepoints [encoding convertfrom utf-32le \x41\x00\x00\x00\x00\xD8\x00\x00\x42\x00\x00\x00]
U+00000041 U+000000F0 U+00000042
Where does the U+000000F0 come from? It seems strange that 0x0000D800 gets mapped to that value. Am I missing something?
Tcl9 seems fine (maps to U+D800)
48bb1e2e08New ticket [203792a48c] Avoid signed integer overflow in Utf32ToUtfProc(). ticket2023-04-22 08:05:33f763b2396eMerge trunk: Final part of [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. Problem was in testcase, not in actual code. check-in2023-03-22 12:25:33fc029613d5Final part of [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. Problem was in testcase, not in actual code check-in2023-02-16 21:29:076349e0c2e1Ticket [10c2c17c32] follow-up. One output char too much with -failindex. check-in2023-02-15 07:21:5526aadbbd1fFix for [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. With testcases (both for utf-32 and utf-16, which had the same bug) check-in2023-02-13 08:39:290bb13aadb6Proposed fix for [10c2c17c32]: UTF-LE32 encoder mapping of surrogates. TODO: testcase check-in2023-02-06 22:43:30
This happens because of the combining behavior of Tcl_UniCharToUtf(), which Tcl 9.0 doesn't do any more by default. Easy to fix. Will do.
You will realize that this is invalid UTF-32. When Tcl_UniCharToUtf() receives an upper surrogate, it will output the first byte of the 4-byte UTF-8 encoding (which is 0xF0, in this case). Feeding Tcl_UniCharToUtf() a lower surrogate will complete the remaining 3 bytes. In case of UTF-32, this combining should not be done, but since Tcl_UniCharToUtf() is used for UTF-16 too, that's where the problem comes from. As you already found out, in Tcl 9.0 this is corrected.
Yes, I know it is invalid UTF-32. I'm adding tests for handling of invalid byte sequences under different profiles. If errors are not raised, the conversion should be consistent which is what I was checking.
Proposed fix [here]
With the proposed fix, all current tests pass in my apn-encoding-profile branch. Just FYI
The bug-fix introduces another (minor) bug. Test-cases added. Still to be fixed.
Fixed [here]
Thanks, Ashok, for the bug-report!
After merging the fix to 9.0, it turns out that (new) testcase encoding-16.15 still fails there (it passes in 8.7). So, cannot close this ticket yet, but moving it 8.7 -> 9.0.
I think there is still an issue even with 8.7, not just 9.
% codepoints [encoding convertfrom -strict -failindex idx utf-32le \x41\x00\x00\x00\x00\xD8\x00\x00\x42\x00\x00\x00]
U+000041 U+00FFFD
% set idx
4
idx is correct but the return value has an extra character.
This is with checkout [84f30c5d4e]
/Ashok
Indeed: [6349e0c2e15e07ab]. Thanks!
Reason for encoding-16.15 failure was in the testcase, not in the code. Fixed now.
So, closing.