From: Logan Capaldo Date: 2006-05-25T11:44:28+09:00 Subject: Re: How does one transform UTF-8 encoded characters to ASCII On May 24, 2006, at 9:36 PM, Sam Roberts wrote: > On Thu, May 25, 2006 at 08:27:46AM +0900, Wes Gamble wrote: >> Paul Battley wrote: >>> Windows Notepad does handle UTF-8, but requires the presence of a >>> BOM >>> (the three bytes "\xef\xbb\xbf") at the start of the file to read it >>> properly. Other, more competent applications may allow you to select >>> the appropriate encoding, or may even automatically detect it. >> I don't really care about Notepad. >> >> I can't get VIM to show this text correctly. > > vim handles utf-8 (if your terminal does!), but also wants a BOM. > > You might be able to tell it that its utf-8 even without the BOM. > >> I want to be able to convert (what I believe to be) UTF-8 into >> Windows-1252 succesfully. > > Doesn't iconv take two args, the input and output character sets? > > Sam > > require 'iconv' from = 'UTF-8' to = 'CP1252' iconvertor = Iconv.new(from, to) s = "String in utf8" string_in_windows1252 = iconvertor.iconv(s) iconvertor.close