Why do I get an “Invalid Byte Sequence in UTF-8” error reading a text file?

前端 未结 5 1627
刺人心
刺人心 2021-01-26 18:26

I\'m writing a Ruby script to process a large text file, and keep getting an odd encoding error. Here\'s the situation:

input_data = File.new(in_path, \'r\').rea         


        
5条回答
  •  日久生厌
    2021-01-26 19:28

    I fail to get an error here on Linux even when the input file is not UTF-8. (I'm using Ruby 1.9.2, as well.)

    Logically, either this problem is linked with OS-X, or it's something to do with your input data. Does it happen regardless of the data in the input file?

    (I realise that this is not a proper answer, but I lack the rep to add a comment. And since no-one has responded yet, I thought it better than nothing...)

提交回复
热议问题