Jos Backus wrote:
> On Sun, May 11, 2008 at 03:28:31PM +0900, Minic Minic wrote:
>> Anyways, I decided to write a SRAM save file editor for a popular
>> GameBoy game. Problem is for some reason putc is writing 2 bytes when
>> ever I try to write 0x0A. It instead writes 0D 0A into the file.
> 
> Looks like you are on Windows. Try opening @SaveFile in binary mode 
> (@SaveFile
> = File.open("fname", "wb")) which prevents LF -> CRLF conversion.

Why would that help?  The output in the file is 0A 0D, which is a 
windows newline.  If the file was not opened in binary mode, that means 
the ruby code must have tried to write '\n' to the file, which ruby then 
converted to the OS's newline, which for windows is 0A 0D.  However, 
getting the string "a + newline" from the user and then chomp()'ing off 
the newline should leave you with "a".  And using putc() to write the 
string "a" to a file does not involve any newlines.




-- 
Posted via http://www.ruby-forum.com/.