Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e98934a90a9557e273b0ddc1252c6a3f7754c18e
Ticket: 461322ffffffffffffffffffffffffffffffffff
regsub trashes encoding?
User & Date: chris_nelson on 2001-09-13 20:15:20
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    On at least Solaris 2.8, a fairly simple, stupid use of [regsub] produces corrupt output.  It may be 
    that it uses some weird encoding.
    
    It seems to be necessary that the expression and the substitute string are the same.  It seems 
    very sensitive to order of operations that preceed it.  I'm fairly confident it has to do with object 
    representation.
    
    The following script:
    
      set pti(a) abcdefghijklmnopqurstuvwxyz
      set b      $pti(a)
      set pti(c) abcdefghijklmnopqurstuvwxyz0123456789
    
      puts "replace \n\t$pti(a)\nwith\n\t$b\nin\n\t$pti(c)"
      puts "string length:[string length $pti(c)]"
      puts "string byte length:[string bytelength $pti(c)]"
    
      regsub $pti(a) $pti(c) $b d
    
      puts "result:\n\t$d"
      puts "string length:[string length $d]"
      puts "string byte length:[string bytelength $d]"
    
    Produces the following erroneous output:
    
      replace 
            abcdefghijklmnopqurstuvwxyz
      with
            abcdefghijklmnopqurstuvwxyz
      in
            abcdefghijklmnopqurstuvwxyz0123456789
      string length:37
      string byte length:37
      result:
            ab?efijklmnopqurstuvwxyz0123456789
      string length:37
      string byte length:41
    
    At times during my quest to build a nice test case, I got 3-5 ?'s at the start of the string and 
    bytelengths up to 45.
    
    NOTE: If 
    
      set pti(a) abcdefghijklmnopqurstuvwxyz
      set b      $pti(a)
    
    is replaced by:
    
      set pti(a) abcdefghijklmnopqurstuvwxyz
      set b       abcdefghijklmnopqurstuvwxyz
    
    the problem does not seem to occur!
    
    
  4. foundin changed to: "obsolete: 8.4a3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "chris_nelson"
  9. subsystem changed to: "43. Regexp"
  10. title changed to: "regsub trashes encoding?"
  11. type changed to: "Bug"