Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5cf3f854fcabc12536a9fe25e124e682cb156cbd3a0f1c007472d42777a12a7e
Ticket: d10d6ddf295864389294b966163a23a58b9a1e72
UTF-16 Unicode escapes should continue to work in version 9.0
User & Date: apnadkarni on 2024-08-13 13:38:26
Changes

  1. icomment:
    > It is about modifying the parser of string literals (and only string literals), to recognize a syntax that was understood by Tcl 8.6.
    
    @bhaible, one more time, parsing of \u syntax has not changed between Tcl 8.6 (any patchlevel) and Tcl 9. Yet another example,
    
    ```
    % package require Tcl
    8.6.14
    % string equal [string index "\ud83d\ude03" 0] "\ud83d"
    1
    ```
    
    If 8.6 was combining surrogates during parsing, the above would have returned 0. Nevertheless, since you are insisting that is the issue, I traced through the code for 8.6 and 9. In both releases, the sequence is recognized in identical fashion, and results in generation of a string with two surrogate code points. You can compare the code in tclParse.c if you are still not satisfied.
    
    Further to illustrate what has been said in earlier with regards to the issue you are facing being related to the *output*, I've modified the tcl8 profile in branch apn-profile-tcl8-surrogates to do the combining of surrogates on output. Here's the result:
    
    ```
    % fconfigure stdout -profile tcl8 -encoding utf-8
    %  puts "\ud83d\ude03"
    😃
    ```
    
    Note use of the profile to change from the `strict` profile. Doing the change to the tcl8 profile could be classified as a bug or a RFE. The latter would require TCT approval so no guarantees it would be done (and the current implementation is incomplete with respect to fragmented sequences). 
    
    I also do not know if that would meet your needs but at least I hope you are convinced the Tcl syntax parser does not have to be changed.
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"