From 7f7cc8280a36c55aa1776f75f3c011e66acada06 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 12 Aug 2013 16:15:32 +0200 Subject: Modernize hancling of encodings Also, instead of converting from utf-8 to iso-8858-1, we do the other way around since we now live in a utf-8 world. --- lib/feed2imap/imap.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/feed2imap/imap.rb') diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb index 60775e2..4c54456 100644 --- a/lib/feed2imap/imap.rb +++ b/lib/feed2imap/imap.rb @@ -144,7 +144,9 @@ class ImapAccount d = f[0].attr['INTERNALDATE'] s = f[0].attr['ENVELOPE'].subject if s =~ /^=\?utf-8\?b\?/ - s = Base64::decode64(s.gsub(/^=\?utf-8\?b\?(.*)\?=$/, '\1')).toISO_8859_1('utf-8') + s = Base64::decode64(s.gsub(/^=\?utf-8\?b\?(.*)\?=$/, '\1')).force_encoding('utf-8') + elsif s =~ /^=\?iso-8859-1\?b\?/ + s = Base64::decode64(s.gsub(/^=\?iso-8859-1\?b\?(.*)\?=$/, '\1')).force_encoding('iso-8859-1').encode('utf-8') end if dryrun puts "To remove: #{s} (#{d})" -- cgit v1.2.3-70-g09d2