Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b64db68593e05eb10b5d616c3704be1d8debd2d4af34ab0cb46af1b591b4199a
Ticket: c5bcbf349489ed5260b2fd21a3d9f7a195d82585
Output of surrogates seems to repeat following character
User & Date: apnadkarni on 2023-02-07 07:56:17
Changes

  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"