Skip to content
Tcl Source Code History Of Ticket c5bcbf3494
Login

History Of Ticket c5bcbf3494

Artifacts Associated With Ticket c5bcbf3494

  1. Ticket change [25b478d9d2] (rid 208587) by apnadkarni on 2023-02-06 17:34:31:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized to:
      See the following output:
      
      ```
      % encoding system
      utf-8
      % puts A\uD800B
      ABB
      % puts A\uD800C
      ACC
      ```
      
      The parsing of the \u sequence seems correct as is the encoder:
      
      ```
      % binary encode hex [encoding convertto [encoding system] A\uDC00B]
      41edb08042
      ```
      
      which seems correct.
      
      It is not clear what should happen on output of a surrogate but this repeating of following character hints at a bug.
      
      /Ashok
      
    5. foundin initialized to: "8.7"
    6. is_private initialized to: "0"
    7. login: "apnadkarni"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "apnadkarni"
    13. subsystem initialized to: "- New Builtin Commands"
    14. title initialized to:
      Output of surrogates seems to repeat following character
      
    15. type initialized to: "Bug"
  2. Ticket change [e174b3183a] (rid 208589) by jan.nijtmans on 2023-02-06 21:25:56:

    1. icomment:
      I cannot reproduce this. On MacOS:
      <pre>
      $ tclsh8.7
      % puts A\uD800B
      A???B
      % puts A\uD800C
      A???C
      % fconfigure stdout -strict 1
      % puts A\uD800B
      error writing "stdout": illegal byte sequence
      A%
      </pre>
      
      My guess is that this depends on the console. Tcl just outputs the (illegal) 3-byte UTF-8 sequence. In Tcl 9.0 it will (properly) throw an exception
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [b64db68593] (rid 208597) by apnadkarni on 2023-02-07 07:56:17:

    1. icomment:
      It's certainly possible it's platform or console dependent. However consider the following code which hints at dependency on the encoding used by the channel driver.
      
      ```
      % puts A\uD800B
      ABB
      % puts [regexp -inline .* A\uD800B]
      error writing "stdout": illegal byte sequence
      ```
      
      The regexp output should be same as its arg. Why the difference in result? Further investigating,
      
      ```
      % string equal A\uD800B [regexp -inline .* A\uD800B]
      0
      % codepoints A\uD800B
      U+00000041 U+0000D800 U+00000042
      % codepoints [regexp -inline .* A\uD800B]
      U+00000041 U+000000F0 U+00000042
      ```
      
      So it seems there is clearly a issue there. Note 9.0 correctly shows the two strings as equal.
      
      It's possible this is also a result of the Tcl_UnicharToUtf (or was it Tcl_UtfToUnichar?) bug you mentioned in the other ticket but something smells off.
      
      Further, I'm surprised that the puts raises and error even though -nocomplainencoding is 1 (default for Tcl8)
      
      ```
      % fconfigure stdout
      -blocking 1 -buffering line -buffersize 4096 -encoding utf-16 -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation crlf -winsize {120 30}
      % puts [regexp -inline .* A\uD800B]
      error writing "stdout": illegal byte sequence
      ```
      
      As an aside, I'm having a bit of hard time with test cases because when results are not as expected, the puts that prints the result raises an exception as above and the entire test run aborts on a failure to print to stdout. That's a separate issue though that I'm fixing in tcltest.
      
      /Ashok
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  4. Ticket change [d676b7dde0] (rid 208598) by apnadkarni on 2023-02-07 08:21:25:

    1. icomment:
      By the way Jan, I'll investigate this further if you don't get to it first and the Tcl_UnichartoUtf fix does not help here. I just need to finish my test suite for the encoding profiles first.
      
      /Ashok
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  5. Ticket change [d329931190] (rid 216246) by apnadkarni on 2023-07-05 09:52:07:

    1. assignee changed to: "jan.nijtmans"
    2. icomment:
      Finally got back to looking at this issue. It appears the surrogate handling in Tcl 8.7 is the cause (9.0 does not have the problem.)
      
      The regexp correctly returns a Tcl_Obj containing a list with a single Tcl_Obj containing 0x00000041, 0x0000D800, 0x00000042.
      
      When this list is printed, the Tcl_Obj.bytes is generated for it in ExtendStringRepWithUnicode in [this](https://core.tcl-lang.org/tcl/file?ci=7a68ac2af72f2ef2&name=generic/tclStringObj.c&ln=4886-4888) loop.
      
      The problem is `Tcl_UnicharToUtf` remembers the presence of the D800 by storing the utf sequence in buf[]. However, on the next iteration (for 0x00000042) this is [ignored](https://core.tcl-lang.org/tcl/file?ci=7a68ac2af72f2ef2&name=generic/tclUtf.c&ln=218) (there is no way for this to be detected as far as I can see). Consequently, the 0xF0 fragment remains as the remnant for the \uD800 transform to utf8.
      
      Jan, assigning to you as I do not grok the whole surrogate handling business in 8.7. In my view it is a valiant attempt to support in 8.7 but keeps throwing up bugs.
      
    3. login: "apnadkarni"
    4. mimetype: "text/x-markdown"
  6. Ticket change [7762f92839] (rid 216265) by jan.nijtmans on 2023-07-06 15:46:26:

    1. icomment: "Fix attempt [ef717df5a5521ef4|here]. Testing ...."
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [6389542b59] (rid 216743) by jan.nijtmans on 2023-07-26 07:19:47:

    1. closedate changed to: "2460151.80541341"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "Should be fixed [07e42778fc2d0a78|here]"
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"