Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d32993119039c0e4586e58bfdd750bdb6fe434e3613310dc547b1b0fd983c7ef
Ticket: c5bcbf349489ed5260b2fd21a3d9f7a195d82585
Output of surrogates seems to repeat following character
User & Date: apnadkarni on 2023-07-05 09:52:07
Changes

  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"