开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜