开发者

Using UNIX linebreaks in Windows Ruby

开发者 https://www.devze.com 2022-12-28 15:18 出处:网络
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百科her

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

精彩评论

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

关注公众号