Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 60ca85afb6a0b7ac7d9635e5c0727fffe392a7993f1f68a308879b6a753226ba
Ticket: d10d6ddf295864389294b966163a23a58b9a1e72
UTF-16 Unicode escapes should continue to work in version 9.0
User & Date: bhaible on 2024-07-01 16:30:16
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    In Tcl 8.x, the only way to write Unicode characters in a way that is independent
    of the encoding of the current locale is through the \uhhhh\uhhhh syntax, where the
    first \uhhhh denotes a "high surrogate" and the second \uhhhh denotes a "low surrogate".
    
    See:
    $ tclsh8.6
    % puts "\ud83d\ude03"
    😃
    % puts "\U0001F603"
    �
    
    Reference: https://www.tcl-lang.org/man/tcl8.6/TclCmd/Tcl.htm#M28
    
    This does not work any more:
    
    $ tclsh9.0
    % puts "\ud83d\ude03"
    error writing "stdout": invalid or incomplete multibyte or wide character
    % puts "\U0001F603"
    😃
    
    Reference: https://www.tcl.tk/man/tcl9.0/TclCmd/Tcl.html#M28
    
    Use of unencoded UTF-8 characters does not work when [encoding system] is different from utf-8.
    
    But it is important to have a way to denote literal strings with Unicode characters that work
      - regardless of current locale, and
      - regardless of the Tcl version.
    This is important e.g. in message catalogs (such as those generated by GNU gettext).
    As it is now,
      - Unencoded UTF-8 characters don't work, because of e.g. ISO-8859-1 locales in Tcl 8.x,
      - \U000hhhhh doesn't work, because of Tcl 8.6,
      - \uhhhh\uhhhh doesn't work, because of Tcl 9.0beta2.
    
    I'm not saying that all of https://core.tcl-lang.org/tips/doc/trunk/tip/497.md is wrong.
    I'm only saying that the parser should recognize the special case of \uhhhh\uhhhh with
    a high surrogate followed by a low surrogate and convert this to a 32-bit Unicode
    code point.
    
  5. foundin changed to: "9.0b2"
  6. is_private changed to: "0"
  7. login: "bhaible"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "2233330cf6146dcc3447bbdcc73be6c76b5b8e35"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "bhaible"
  14. subsystem changed to: "45. Parsing and Eval"
  15. title changed to:
    UTF-16 Unicode escapes should continue to work in version 9.0
    
  16. type changed to: "Bug"