From a4b2009f2c5a762eee525afe5c71c816ad02e35e Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 22 Dec 2007 08:00:04 +0000 Subject: * lib/net/imap.rb (encode_utf7): accept UTF-8 strings. * lib/net/imap.rb (decode_utf7): return UTF-8 strings. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 540e36672..2398a5d10 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -852,19 +852,19 @@ module Net end base64.unpack("m")[0].unpack("n*").pack("U*") end - } + }.force_encoding("UTF-8") end # Encode a string from UTF-8 format to modified UTF-7. def self.encode_utf7(s) - return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/n) { |x| + return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { |x| if $1 "&-" else base64 = [x.unpack("U*").pack("n*")].pack("m") "&" + base64.delete("=\n").tr("/", ",") + "-" end - } + }.force_encoding("ASCII-8BIT") end private -- cgit