Tcl_UniCharToUtf() not conform to documentation
The documentation of Tcl_UniCharToUtf() says:
Tcl_UniCharToUtf stores the Tcl_UniChar ch as a UTF-8 string in starting at buf. The return value is the number of bytes stored in buf.
But Tcl_UniCharToUtf(0,buf) stores "\300\200" into buf, this is not an UTF-8 string, it's an anomaly (belongs to MUTF-8), not conform to UTF-8 standard. Either Tcl_UniCharToUtf is erroneous, or the documentation is incomplete.
This is a severe problem. If anybody is using this function to store an UTF-8 string in a database, trusting the documentation, it might happen that the database become damaged, because in general no other (properly implemented) UTF-8 based tool is interpreting the anomaly "\300\200". Please note that UTF-8 is not MUTF-8.
BTW: The formats MUTF-8, WTF-8, and CESU-8 are not really encoding formats. They are more or less invented for designating results of erroneous UTF-8 implementations, especially the thing with surrogates, a result of an accident (programming error). It's embarrassing if corporates like Microsoft, Sun, et al, are declaring these ill-formed UTF-8 encodings as "UTF-8". Free software should not follow the way of corporates. Here it means: if the result of Unicode point zero is not UTF-8 (RFC3629), then this should be explicitly documented.
Dup of [0e10a7197f61c2aa7e436edf75ed24bdfe47ef6c] I don't intend to spend any time on this. If you have suggestions how to improve the documentation, that will be appreciated. Since Tcl depends on this behavior (for handling byte arrays containing 0x00), it simply cannot be changed. EIAS!
> If you have suggestions how to improve the documentation, that will be appreciated.
But this was a suggestion how to improve the documentation, your answer makes no sense for me. Because of the severity and the fact, that the functionality of Tcl_UniCharToUtf() is not conform to documentation, it was reported as a bug.
So this is another ignored bug report, I'm not wondering that Tcl is not very popular.
My suggestion is: in stead of filing tickets, just edit the documentation and commit the improvements (you have the rights, don't you?).
You are doing that for Tk (see http://core.tcl.tk/tcl/info/9b324dcab5ec5340), please start doing that for Tcl as well.
If you want someone review your proposed changes, just commit to a branch and ask. I really don't see the point in filing tickets for this.
> My suggestion is: in stead of filing tickets, just edit the documentation and commit the improvements (you have the rights, don't you?). Yes, I have the rights. The thing is that I'm not a Tcl developer, so I don't want to edit foreign sources. (I have the rights because I have to do minor corrections/additions for the generation of the Tk Text Widget HTML manual.) > You are doing that for Tk (see http://core.tcl.tk/tcl/info/9b324dcab5ec5340), please start doing that for Tcl as well. But if you say I should edit the documentation, so I will do it.