Axel Etzold wrote: >> > $KCODE = 'u' >> > (from here: >> > >> > Thank you very much! >> >> >> Your data is not UTF-8, from the error, most likely iso-8859-1 (or 15) >> >> man iso_8859-1 shows octal 351 as expected. >> >> 351 233 E9 LATIN SMALL LETTER E WITH ACUTE >> >> -jh > > Dear Jonathan, > > thanks for the hint. You are right. I corrected the encoding > of the file I read the text in from, > > $KCODE = 'u' > require 'iconv' > s=IO.readlines("/home/axel/text.txt").to_s > p s # => > 'caffè§ ic_translit = Iconv.new('US-ASCII//TRANSLIT', 'UTF-8') > puts ic_translit.iconv(s) # => caff`e > > However, now I still get > "caff?" instead of "caff`e" as promised. > Try running this code: require 'iconv' s = "caf\_x_c3\_x_a9" #remove underscores p s #I see: caf\_303\_251 (without the underscores) #\_303\_251 (without the underscores) is the utf-8 #encoding in octal format. I really hate that ruby #displays octal format instead of hex format! ic_translit = Iconv.new('US-ASCII//TRANSLIT', 'UTF-8') new_s = ic_translit.iconv(s) # => caff`e p new_s #I see: caf'e -- Posted via http://www.ruby-forum.com/.