B
billbell52
I am trying to write a text file on Unix (via Samba) from a Ruby
program running on the PC. I am trying to get the end of line
correct. I cannot get the Unix newline character (0x0a) in the file.
I am getting the same results when writing to either the PC or Linux
so Samba is not the issue. How do you do this?
tf = "S:/open/test_ending.txt" # Unix
#tf = "C:/temp/test_ending.txt" # PC
fo = File.open(tf, "w")
text = "this is line ending lf-r\r"
fo.write(text) # puts an OD (cr) at end of line
text = "this is line ending crlf\n"
fo.write(text) # puts an 0D0A at end of line
text = "this is line ending 0x0a"
fo.write(text)
fo.putc 0x0a # puts an 0D0A at end of line - Weird
text = "this is line ending 0x0d"
fo.write(text)
fo.putc 0x0d # puts an 0D at end of line
fo.close
# I cannot get a linefeed (newline 0x0a) in the file.
# results of writing to unix and pc are the same.
program running on the PC. I am trying to get the end of line
correct. I cannot get the Unix newline character (0x0a) in the file.
I am getting the same results when writing to either the PC or Linux
so Samba is not the issue. How do you do this?
tf = "S:/open/test_ending.txt" # Unix
#tf = "C:/temp/test_ending.txt" # PC
fo = File.open(tf, "w")
text = "this is line ending lf-r\r"
fo.write(text) # puts an OD (cr) at end of line
text = "this is line ending crlf\n"
fo.write(text) # puts an 0D0A at end of line
text = "this is line ending 0x0a"
fo.write(text)
fo.putc 0x0a # puts an 0D0A at end of line - Weird
text = "this is line ending 0x0d"
fo.write(text)
fo.putc 0x0d # puts an 0D at end of line
fo.close
# I cannot get a linefeed (newline 0x0a) in the file.
# results of writing to unix and pc are the same.