Skip to content
Tcl Source Code View Ticket
Login

View Ticket

-translation binary misinterpreted as -transation lf

Closed / Invalid218403ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:57:09
OriginalBugID: 5296 Bug
Version: 8.3
SubmitDate: '2000-04-28'
LastModified: '2000-05-08'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: Solaris
FixedDate: '2000-10-25'
ClosedDate: '2000-05-08'


Name:
Donal Fellows

Comments:
The only user-level work-around is to manipulate the data at the C
    level, which stinks big-time.

ReproducibleScript:
set f [open [info nameofexecutable] r] ;# Could be any file
puts [fconfigure $f -translation]
fconfigure $f -translation binary -encoding binary
puts [fconfigure $f -translation]
close $f

ObservedBehavior:
The above script outputs the following:
  auto
  lf
Thus, putting the channel into binary mode has in fact made it switch into changing all CRLF sequences in the data into single LFs.  This is a great way to corrupt data being read from a binary file (I found this when trying to write a PNG file reader) and is _utterly_ wrong...

DesiredBehavior:
It should output:
  auto
  binary
And having set the encoding and translation to binary for a channel, I should just get the bytes that are being passed along that channel.



This is actually correct, although confusing.  The point of
translation is that it tells us what we are converting externally
into the internal linefeed char (which is LF).  With -binary,
this means only lf == LF, which is the correct noop to give us
binary translation. 
-- 05/08/2000 hobbs
welch Closed ticket [218403ffff]. [History diff]2000-10-26 08:21:18
dgp Ticket [218403ffff]: 4 changes [History diff]2001-04-03 07:07:19
Log in (anonymous is fine) to add a comment.