N
N
NakedFace2016-01-24 18:07:03
ruby
NakedFace, 2016-01-24 18:07:03

How to output Russian letters from a file to the Ruby console?

Hello!
I'm just starting to learn ruby, I had such a question.
There is a csv file, I'm parsing it and I want to output the contents to the console.
But instead of the Russian text, encoding errors appear.
Moreover, if you simply write puts "Hi" - Russian letters are displayed correctly.
The file encoding is utf-8.
How to fix it?
Ruby version 2.1.7
Thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2016-01-25
@NakedFace

Find out what encoding your file is in and open it in this encoding. For example File.open or CSV.open can take an encoding parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question