summaryrefslogtreecommitdiff
path: root/lib/feed2imap
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/imap.rb4
-rw-r--r--lib/feed2imap/rexml_patch.rb2
2 files changed, 4 insertions, 2 deletions
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})"
diff --git a/lib/feed2imap/rexml_patch.rb b/lib/feed2imap/rexml_patch.rb
index f991090..7016127 100644
--- a/lib/feed2imap/rexml_patch.rb
+++ b/lib/feed2imap/rexml_patch.rb
@@ -26,7 +26,7 @@ require 'feedparser'
module REXML
module Encoding
def decode(str)
- return str.toUTF8(@encoding)
+ return str.encode(@encoding)
end
def encode(str)