Ruby/File Directory/set encoding

Материал из Wiki.crossplatform.ru

Версия от 17:57, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Latin-1, transcoded to UTF-8

f = File.open("data.txt", "r")   # Open file data.txt for reading
f.set_encoding("iso-8859-1", "utf-8") # Latin-1, transcoded to UTF-8
f = File.open("data.txt", "r")   # Open file data.txt for reading
f.set_encoding("iso-8859-1:utf-8")    # Same as above



UTF-8 text

f = File.open("data.txt", "r")   # Open file data.txt for reading
f.set_encoding(Encoding::UTF-8)       # UTF-8 text