Skip to content
Tcl Source Code History Of Ticket 218406
Login

History Of Ticket 218406

Artifacts Associated With Ticket 218406

  1. Ticket change [09ce9b3441] (rid 113718) by nobody on 2000-10-26 00:57:11:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 5336 Bug
      Version: 8.3.1
      SubmitDate: '2000-05-03'
      LastModified: '2000-08-15'
      Severity: MED
      Status: Closed
      Submitter: angie
      ChangedBy: ericm
      OS: Windows 98
      Machine: pentium II
      FixedDate: '2000-10-25'
      ClosedDate: '2000-08-15'
      
      
      Tcl 8.3.1 Bug
      
      Name:  doug edmunds
      email:  [email protected]
      Support:  None
      Severity:  3
      OperatingSystem:  Windows 98
      Machine:  pentium II
      Synopsis:  unicode BOM not removed
      
      ReproducibleScript:
      BOM = Byte Order Mark sometimes placed at beginning of utf-16 files
      either FEFF or FFFE, signifying little-endian or big-endian format.
      
      
      1. "encoding convertfrom unicode"
      #fn is a unicode utf-16 file
      proc read_unifile {fn} {
       set f [open $fn r]
       set text [encoding convertfrom unicode [read $f ]]
       close $f
       return $text
       }
      call proc:  
      set result [read_unifile unifile.txt] 
      set $result  <<BOM not removed
      
      2.  fconfigure $file -encoding unicode
      
        proc file:uread {fn} {
          set encoding ""
          set f [open $fn r]
          if {[info tclversion]>=8.1} {
              gets $f line
              if {[regexp \xFE\xFF $line]||[regexp \xFF\xFE $line]} {
                  fconfigure $f -encoding unicode
                  set encoding unicode
              }
              seek $f 0 start ;# rewind -- real reading is still to come
          }
          set text [read $f [file size $fn]]
          close $f
          if {$encoding=="unicode"} {
      regsub -all "\uFEFF|\uFFFE" $text "" text
          }
          return $text
        }
      
      set result [file:uread unifile.txt] 
      set $result  <<BOM was not removed
      
      
      ObservedBehavior:
      BOM must be manually removed.
      If the unicode file being read in will be evaluated,
      it will fail as a script, as in
      eval $result
      
      
      DesiredBehavior:
      BOM, if present, automatically removed when file is loaded
      
      Patch:
      assuming string that file is stored into is named $text
      
      regsub -all "\uFEFF|\uFFFE" $text "" text
      
      
      My reading of the UTF BOM FAQ is that Tcl should _not_ automatically remove the BOM.  The use of a BOM is protocol dependant, so information about its presence or absence may be relevant to a developer using Tcl.  In addition, depending on the protocol, the BOM may actually be data (specifically, a zero-width non-breaking space), so removing it could be incorrect.
      
      Please correct me if I am wrong; my information is derived from the UTF/BOM FAQ at:
      
      http://www.unicode.org/unicode/faq/utf_bom.html
      
         Eric Melski                            The Other Tcl Guy
         ericm at ajubasolutions.com            Ajuba Solutions
      
      -- 08/15/2000 ericm
      
      
      
    4. foundin initialized to: "obsolete: 8.3.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "57. zlib"
    10. title initialized to: "unicode BOM not removed"
    11. type initialized to: "Bug"
  2. Ticket change [0d3b611b7a] (rid 114323) by welch on 2000-10-26 08:21:18:

    1. closedate changed to: "2000-10-26T01:21:18"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [6c62f68527] (rid 128502) by dgp on 2001-04-06 03:26:08:

    1. closedate changed to: "2001-04-05T20:26:08"
    2. closer changed to: "dgp"
    3. subsystem changed to: "25. Channel System"