Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c912054732ceae5dd1ef883db74fc0f911508ec26f1c80a2f2b831cf70166a2f
Ticket: e617e8a71a00496e9ec682caa1b4e7b5b98c55a7
comparing UTF-16 strings doesn't account for surrogates
User & Date: dgp on 2020-04-29 17:50:02
Changes

  1. icomment:
    
    First attempt at a fix committed. It exposes trouble with the interface.
    
    The routine signature is
    
    Tcl_UniCharNcasecmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars)
    
    The numChars argument name suggests we should count chars, but we've
    been counting UCS-2 code units.  As we enter a world where those are not
    the same thing, we have to re-specify what the argument should be taken to mean.
    
    If callers think of the argument as the number of UCS-2 code units, the length
    of sub-array, then the calls can stay unchanged, but when that number splits
    a character, we'll get nonsense results, as seen in this first attempt.
    
    We want to compare the character \uFFFF against the character \uD800\uDC00
    but the (numChars = 1) argument prevents us taking the low surrogate into account
    as we must do to get the right answer.
    
  2. login: "dgp"
  3. mimetype: "text/plain"