|
2022-12-30
| ||
| 20:41 | • Ticket [084ab982fe] Use -strict to disable noncharacters status still Closed... artifact: 14e0e130d3 user: pooryorick | |
|
2022-12-29
| ||
| 23:42 | • Closed ticket [084ab982fe]. artifact: 7d223a8da8 user: jan.nijtmans | |
|
2022-12-26
| ||
| 20:31 | • Open ticket [084ab982fe]. artifact: 77874b2e46 user: pooryorick | |
|
2022-12-16
| ||
| 09:41 | • Ticket [084ab982fe]: 5 changes artifact: 9f94911429 user: jan.nijtmans | |
| 09:40 | Follow-up for [084ab982fe]: Use -strict to disable noncharacters. This change was only done for utf-... check-in: b7da2f7465 user: jan.nijtmans tags: core-8-branch | |
|
2022-12-13
| ||
| 07:59 | • Closed ticket [17a1cb8d6e]: Tcl 9: "illegal byte sequence" ?! plus... artifact: af5373e31b user: jan.nijtmans | |
|
2022-12-02
| ||
| 12:42 | • Ticket [084ab982fe] Use -strict to disable noncharacters status still Closed... artifact: 82f589be52 user: jan.nijtmans | |
| 12:14 | • Ticket [084ab982fe]: 5 changes artifact: 6ac65cb756 user: pointsman | |
|
2022-12-01
| ||
| 07:46 | • Closed ticket [084ab982fe]. artifact: 69ee650a81 user: jan.nijtmans | |
|
2022-11-30
| ||
| 10:48 | Fix for [084ab982fe]: Use -strict to disable noncharacte check-in: 9619dddce6 user: jan.nijtmans tags: core-8-branch | |
|
2022-11-29
| ||
| 17:22 | • Ticket [084ab982fe] Use -strict to disable noncharacters status still Open w... artifact: 30a22094e9 user: oehhar | |
| 14:51 | Proposed fix for [084ab982fe]: Use -strict to disable noncharacters closed check-in: ec0c7045df user: jan.nijtmans tags: rfe-084ab982fe | |
| 11:53 | • Ticket [084ab982fe] Use -strict to disable noncharacters status still Open w... artifact: 5d1cea1a40 user: jan.nijtmans | |
| 11:51 | • New ticket [084ab982fe]. artifact: 6821bbf933 user: jan.nijtmans | |
Use -strict to disable noncharacters
Look at this:% info patchlevel 9.0a4 % encoding system utf-8 % puts \uffff error writing "stdout": illegal byte sequence
Although this was on purpose, TIP #346 could be used to reduce the surprise here: When -strictencoding is specified, disallow non-characters, otherwise allow them. The same will be done on 'encoding convertto utf-8' as well. (since the -strict handling is built-in in the utf-8 encoder/decoder)
b7da2f7465Follow-up for [084ab982fe]: Use -strict to disable noncharacters. This change was only done for utf-8, but the same change should be done for utf-16 and utf-32 too check-in2022-12-16 09:40:03af5373e31bClosed ticket [17a1cb8d6e]: Tcl 9: "illegal byte sequence" ?! plus 7 other changes ticket2022-12-13 07:59:459619dddce6Fix for [084ab982fe]: Use -strict to disable noncharacte check-in2022-11-30 10:48:4030a22094e9Ticket [084ab982fe] Use -strict to disable noncharacters status still Open with 4 other changes ticket2022-11-29 17:22:09ec0c7045dfProposed fix for [084ab982fe]: Use -strict to disable noncharacters check-in2022-11-29 14:51:03
Great implementation with test-cases in light speed by Jan: [084ab982fe]
Thank you, I appreciate, Harald
Fixed [here]
One thing is probably not made clear enough by me (probably because I'm in fact try to not sound "a little sharp on the vocal level", although sometimes obviously failing).
Why do we have the fconfigure -strict mode at all?
The current default is "strict" in the sense of eg. python, that means: raise error on surrogate. Addionally there is -nocomplain, passing all code-points through. Both modes are fine and understandable to have.
Additionally we the mode -strict 1 (which is a bit a confusing name) which raises error on surrogate and noncharacter.
This surely is a "feature" in the sense it has a defined behaviour. But what is the use case? Who needs this? Is this not an more obscure than just minor feature?
Especially since there is also the [string is unicode] feature. An IMHO gross misnomer, did I said this already?
If someone wants the behaviour this fconfigure -strict 1 feature provides one can always do
if {[string is unicode $mystring]} {
puts $chan $mystring
} else {
# Handle case of mystring with noncharacter
}
instead of
if {[catch {puts $chan $mystring}]} {
# Handle case of mystring with noncharacter
}
> Additionally we the mode -strict 1 (which is a bit a confusing name) which raises error on surrogate and noncharacter.
The "-strict 1" mode does more than only raising errors on noncharacters. The default utf-8 decoder tries to correct obvious error, in 'strict' mode it doesn't do that any more. e.g.:
$ tclsh9.0 % encoding convertfrom utf-8 \xA1 ¡ % encoding convertfrom -strict utf-8 \xA1 unexpected byte sequence starting at index 0: '\xA1' %
'-strict 1' mode is a flag, whose behavior is implemented by every encoder/decoder separately.
Follow-up [here]. If we change the behavior of -strict for utf-8, we should do the corresponding change on utf-16 and utf-32 too.
Overloading -strict for this purpose is incorrect, as -strict should be dedicated to how to handle invalid data in an encoding, not on choosing which data to consider invalid. This is a separate concern that should be handled by separate options. By default, an encoder/decoder should conform to the specification, and options can be provided to direct the encoder/decoder to deviate in some way. In this case, a suitable option might be -onlychars 1, with the default being -onlychars 0 to conform to the specification. There could be additional options such as -surrogates 1 (default is -surrogates 0) and -nonchars 0 (default is -nonchars 1). This is more complicated, but oversimplification can be a bad thing. The Unicode specification entails a certain amount of complexity, and there is no way around that. In the case of Unicode, the proper target for Tcl is fidelity.
pooryorick's last comment is out-of-date, since the behavior of -strict is already modified to be more conform 'strict'-ness as described by the Unicode consortium. So, closing (again)
See issue report [17a1cb8d6e2a51bd] for further details.