Using UNIX linebreaks in Windows Ruby
Is it possible to tell Ruby in Windows to use only \n instead of r\n? I'm having an issue where a file is being saved with \r\n and it is causing it to not function properly. Is t开发者_JS百科here a setting somewhere I can change to fix this?
The simple attack:
File.open("foo.txt", "w") do |fd|
fd.write "this\nis\a\test\n"
end
And when I open this in hexedit:
00000000 74 68 69 73 0A 69 73 0A 61 0A 74 65 73 74 0A
^^ ^^ ^^ ^^
\n \n \n \n
精彩评论