| Ticket UUID: | 80d4c1c7e5393907df677e56ccc41bb78ffafe19 | ||
| Title: | Isolated surrogates are not replaced when encoding to / from utf-8 | ||
| Type: | Bug | Created on: | 2024-02-06 11:38:47 |
| Submitter: | apnadkarni | Assigned to: | apnadkarni |
| Subsystem: | 44. UTF-8 Strings | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2024-02-07 03:09:46 |
| Status: | Closed | Closed by: | apnadkarni |
| Resolution: | Fixed | Closed on: | 2024-02-07 03:09:46 |
| Version: | 9.0 | ||
| Description: | ||||
|
Isolated (unpaired) surrogates should be treated as encoding errors. Example:
The above is correct as U+D800 should not appear as an isolated surrogate code point. However the following is not,
eda080 is the utf-8 for U+D800. The output have been efbfbd (U+FFFD replacement char). In principle, any time the strict profile raises an error, the replace profile should be substituting the replacement character. Jan, your thoughts? | ||||
| User Comments: | ||||
jan.nijtmans added on 2024-02-06 12:18:45:
It looks like you forgot the "-profile replace" handling here: https://core.tcl-lang.org/tcl/file?name=generic/tclEncoding.c&ci=f1cef9d6c96f7ce5&ln=2595-2607 Agreed jan.nijtmans added on 2024-02-06 12:30:54:
Hmmmm. I now see the PROFILE_REPLACE handling just above that ...... I don't know why it's not working as expected then. jan.nijtmans added on 2024-02-06 13:03:41:
Proposed fix [c37652549ee69fa2|here] In 8.7 it appears to work as expected, but in 9.0 "-profile replace" handling was lacking for this specific case. Do you want to add a testcase? apnadkarni added on 2024-02-06 13:15:28:
Fix seems reasonable. If you commit it, I'll the test cases. jan.nijtmans added on 2024-02-06 13:22:55:
Committed now apnadkarni added on 2024-02-07 03:09:46:
Added tests. Closing. | ||||
