Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9f08cfd7752f9d4f327a19e8ffd5b214a72269bef0f3f79c5874e60a7f80e6d3
Ticket: 81242a48c80efaecf2c70271cafa2c2a0a3bf126
Documentation for Tcl_UtfAtIndex() is incorrect
User & Date: jan.nijtmans on 2020-05-12 13:56:12
Changes

  1. icomment:
    It turns out that the additional call to Tcl_UtfToUniChar() is neccessary. Leaving it out makes it possible to create a pointer in the middle of a surrogate pair. There are two testcases detecting this:
    
    <pre>
    ==== string-17.9.0 string totitle, surrogates, bug [11ae2be95dac9417] FAILED
    ==== Contents of test case:
    
        run {list [string totitle a\U118c0c 1 1] [string totitle a\U118c0c 2 2]  [string totitle a\U118c0c 3 3]}
    
    ---- Result was:
    að‘£€c að‘£€c að‘£€C
    ---- Result should have been (exact matching):
    að‘¢ c að‘£€C að‘£€C
    ==== string-17.9.0 FAILED
    
    
    
    ==== string-17.9.1 string totitle, surrogates, bug [11ae2be95dac9417] FAILED
    ==== Contents of test case:
    
        run {list [string totitle a\U118c0c 1 1] [string totitle a\U118c0c 2 2]  [string totitle a\U118c0c 3 3]}
    
    ---- Result was:
    að‘£€c að‘£€c að‘£€C
    ---- Result should have been (exact matching):
    að‘¢ c að‘£€C að‘£€C
    ==== string-17.9.1 FAILED
    
    </pre>
    
    So, the extra Tcl_UtfToUniChar() call is necessary.
    
  2. login: "jan.nijtmans"
  3. mimetype: "text/x-fossil-wiki"