help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing binary files is not working properly


From: Przemek Klosowski
Subject: Re: Writing binary files is not working properly
Date: Mon, 27 Oct 2003 09:30:31 -0500 (EST)

   robert Macy wrote:

   | In other words, fwrite(fid,sig,'ushort'); is adding a
   | "carriage return" everytime the data has "new line"
   |

   Looks like your problem could be due to the way various operating
   systems mark the end of lines in text files
           ...
   There are utilities available that can convert files from one form to
   the other: http://www.google.com/search?q=dos2unix

But, it's in general impossible to fix up a binary file a posteriori,
because you can't know if 0x0d 0x0a is a result of botched line ending
fix or a real data from the file.

On a Windows platform, you need to use the 'wb' mode in the fopen()
call.  I don't know when it was introduced but I checked that it is
there in 2.1.40; check your own version. This actually probably should
be a default for wavwrite.m, because it should work right on Windows/Mac
and should not make a difference on Unix. Could you check and submit 
a patch if it's correct?

      p




PS. Actually, it's surprising that the problem only happens for 16-bit
data; a non-binary mode should expand every 0d value... perhaps there
just weren't any in your 8-bit files??



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]