Writing <lf> verbatim to file opened in text mode

M

mortenf

I am in need of a method of writing a byte sequence to a file opened in
text mode without translating <lf> ('\n') to <cr><lf> when compiling
for MSDOS platform. Is there a way of skipping this translation and
write the byte sequence byte by byte to the file?

Alternatively, I could open the file in binary mode, but then I need to
figure out how to write real end lines (<lf>, <cr> or <cr><lf>)
according to the target platform.

Best regards
Morten Frederiksen
 
J

Jim Langston

I am in need of a method of writing a byte sequence to a file opened in
text mode without translating <lf> ('\n') to <cr><lf> when compiling
for MSDOS platform. Is there a way of skipping this translation and
write the byte sequence byte by byte to the file?

Alternatively, I could open the file in binary mode, but then I need to
figure out how to write real end lines (<lf>, <cr> or <cr><lf>)
according to the target platform.

You're confusing me here. First you say you don't want to translate '\n' to
<cr><lf>, then later you say if you use binary you have to figure out how to
write <lf>, <cr> or <cr><lf> according to the platform.

Which is it?

Carriage return is 0D hex, line feed is 0A hex or 13 and 10 respectively.

I think you just need to use binary mode.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top