ruby - Saving a file with a Cyrillic name -
how correctly save file cyrillic name?
now file name looks this: "Максим Р—РёРЅСЏРєРѕРІ feat. indigo - , me only". correct name "Максим Зиняков feat. indigo - , me only".
i file http url:
agent = mechanize.new agent.get(url).save_as("#{mp3_dir}/#{title}.mp3")
as mentioned, need convert title
string utf-8 using iconv
:
require 'rubygems' require 'mechanize' require 'iconv' agent = mechanize.new # if source encoding indeed windows-1251, 'from' cp1251 title = iconv.conv('utf8', 'cp1251', title) agent.get(url).save_as("#{mp3_dir}/#{title}.mp3")
Comments
Post a Comment