open(DATAFEED_URI) do |file|
local_filename = local_path
local_filename.open('w') do |outf|
file.each do |line|
begin
outf.write Iconv.conv('UTF-8//TRANSLIT//IGNORE',
'WINDOWS-1252', line)
rescue Iconv::IllegalSequence => e
shlogger.error { "#{DATAFEED_URI} line #{file.lineno}
could not be translated:\n#{line}" }
end
end
end
local_filename.open('r') {|opened| yield opened }
end
The part that you're going to be interested in is the line that calls
Iconv and, in particular, the second argument of 'WINDOWS-1252' which
is likely the encoding of your data. There are also a couple aliases
for that code page:
$ iconv -l | grep -e 1252
CP1252 MS-ANSI WINDOWS-1252
(`iconv -l` prints a list of all the encodings known by iconv.)
I hope that helps.
-Rob
> --
> You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-
> ta...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
> .
>
Rob Biedenharn
R...@AgileConsultingLLC.com http://AgileConsultingLLC.com/
r...@GaslightSoftware.com http://GaslightSoftware.com/
I'm using Rails in a Microsoft platform, so I can't rely use iconv,
I had a lot of problems with encoding, and finally I solved with the
attached script.
I hope it will help you!
El 21/06/2011 1:33, Erica escribi�:
--
Miquel Cubel Escarr�
+34 699 73 22 46
mcu...@gmail.com
"Computers are good at following instructions, but not at reading your mind." Donald Knuth.
"Los ordenadores son buenos siguiendo instrucciones, pero no leyendo tu mente." Donald Knuth.