System new line separator in Ruby

前端 未结 3 2031
青春惊慌失措
青春惊慌失措 2021-01-18 10:53

How can I determine new line separator used by OS (LF, CR/LF or other), in Ruby?

3条回答
  •  执念已碎
    2021-01-18 11:44

    File.open("some_temporary_file", "w") { |file| file.puts }
    new_line_separator =
      File.open("some_temporary_file", "rb") { |file| file.read }
    

提交回复
热议问题