Overview
| Artifact ID: | 7b247f5d108eb29fbee22656337ef82a268c24404969f5c99ca2370836b77bda |
|---|---|
| Ticket: | e2eac30e4192a9d26fad9b1771d7b391d7e2592b
incorrect result of convertfrom with 4-byte utf8-characters |
| User & Date: | jan.nijtmans on 2022-03-24 16:18:35 |
Changes
- assignee changed to: "jan.nijtmans"
- icomment:
Thanks for the bug-report. The tricky thing is that the encoding functions Tcl_ExternalToUtf() and Tcl_UtfToExternal() should work with a buffersize of TCL_UTF_MAX=3, which is not enough to handle utf-8 sequences of 4-bytes. In Tcl 8.6 that was no problem, because Tcl 8.6 uses the cesu-8 encoding internall, in which such characters are split (internally) in two surrogates. But in Tcl 8.7, this changed, which is causing this bug. There are two ways to solve it. 1) Implement a small buffer in the channel state. 2) Increase TCL_UTF_MAX to 4 internally. The second fix is currently ongoing in branch [https://core.tcl-lang.org/tcl/timeline?r=full-utf-for-87|full-utf-for-87], but it needs a [https://core.tcl-lang.org/tips/doc/trunk/tip/622.md|TIP]. I already checked: it looks like this bug is - indeed - fixed in [https://core.tcl-lang.org/tcl/timeline?r=full-utf-for-87|full-utf-for-87]: <pre> $ tclsh8.7 % tcl::build-info 8.7a6+e75009fecdf4135dbff928da58b8964909760bc755c7713dc2f6bb4f824c158c.gcc-1102 % encoding convertfrom utf-8 [string repeat \xF0\x9f\x92\x95 51] 💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕 </pre> Hope this helps, Jan Nijtmans - login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"