P
P
Peter2014-11-05 00:09:14
Ruby on Rails
Peter, 2014-11-05 00:09:14

How to convert Russian text to utf-8 using Ruby?

Please advise some kind of gem for automatic encoding detection that would work with Russian characters.
As an example, you need to recognize the encoding and recode the text of the title of a Russian song into utf-8:
Input: ÌÎÐÑÊÀß ×ÅÐÅÏÀØÊÀ
Output:МОРСКАЯ ЧЕРЕПАШКА

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily, 2014-11-05
@vsadm

apt-get install enca

require 'open3'

def detect_and_convert(str)
  stdout, stderr, status = Open3.capture3('enca -c', :stdin_data => str)
  stdout
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question