Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl 8.1 writes incorrect UTF-16 files

Closed / Invalid219288ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2000-10-26 05:10:03
OriginalBugID: 2128 Bug
Version: 8.1
SubmitDate: '1999-05-26'
LastModified: '1999-10-21'
Severity: MED
Status: UnAssn
Submitter: pat
ChangedBy: hobbs
RelatedBugIDs: 2129
OS: Linux
OSVersion: Debian 2.0
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name:
Victor Wagner

ReproducibleScript:
fconfigure stdout -encoding unicode
    puts "some stuff"

ObservedBehavior:
According to UTF-16 standard, any UTF-16 file should begin with 
    Unicode character "\uFEFF", which allows unicode reading software to
    determine byte order of writing software correctly.
    Any occurence of this 
    Tcl doesn't automatically write this character. I haven't tested it
    on machines with different byte order, but I suspect that unicode file
    written on Sparc wouldn't be readable on Intel and vice versa.

DesiredBehavior:
Upon first write of file with encoding set to unicode (or directly at
    the
    moment of fconfigure) tcl should write "\uFEFF" to file. Extra \uFEFF
    shouldn't harm becouse this symbol is defined in UNICODE as zero-width
    non-breakable space (effectively noop)
dgp Ticket [219288ffff]: 1 change [History diff]2001-04-06 03:08:43
dkfplain2001-10-07 18:56:16
Logged In: YES 
user_id=79902

Probably easier to do it from [fconfigure] with some special code to notice when an encoding that needs 
a BOM is selected and write it (into our output buffer) at that point.
andreas_kupriesplain2001-10-09 22:19:03
Logged In: YES 
user_id=75003

Unconditional write, even if the channel is not a file, but 
a socket, or pipe ?

See also #219289.
hobbsplain2001-10-10 05:19:27
Logged In: YES 
user_id=72656

This is something for the application developer, not Tcl, 
to write.  The only thing that Tcl doesn't handle, and 
isn't really requested here, is the ability to write out 
utf-16 in a different byte order than the system one.  The 
read-side (219289) is slightly different, in that Tcl 
should provide the ability to read utf-16 from any byte-
order.
Log in (anonymous is fine) to add a comment.