Artifacts Associated With Ticket 218406
Ticket change [09ce9b3441] (rid 113718) by nobody on 2000-10-26 00:57:11:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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
- foundin initialized to: "obsolete: 8.3.1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "57. zlib"
- title initialized to: "unicode BOM not removed"
- type initialized to: "Bug"
Ticket change [0d3b611b7a] (rid 114323) by welch on 2000-10-26 08:21:18:
- closedate changed to: "2000-10-26T01:21:18"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [6c62f68527] (rid 128502) by dgp on 2001-04-06 03:26:08:
- closedate changed to: "2001-04-05T20:26:08"
- closer changed to: "dgp"
- subsystem changed to: "25. Channel System"