summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-02 10:05:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-02 10:05:19 +0000
commitf8fc9136223c83c2791566d3efa52843f89aa127 (patch)
tree166e0d413670f87d7594cda8bf9d8f504eb75b94 /lib
parentb6fe3dae4de7002c2f58bc9cfb993033dff7927d (diff)
some patches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/base64.rb26
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/base64.rb b/lib/base64.rb
index 96208a6..8b75dda 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -1,3 +1,5 @@
+require "kconv"
+
def decode64(str)
string = ''
for line in str.split("\n")
@@ -10,30 +12,18 @@ def decode64(str)
return string
end
-def j2e(str)
- while str =~ /\033\$B([^\033]*)\033\(B/
- s = $1
- pre, post = $`, $'
- s.gsub!(/./) { |ch|
- (ch[0]|0x80).chr
- }
- str = pre + s + post
- end
-# str.gsub!(/\033\$B([^\033]*)\033\(B/) {
-# $1.gsub!(/./) { |ch|
-# (ch[0]|0x80).chr
-# }
-# }
- str
-end
-
def decode_b(str)
str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
decode64($1)
}
+ str = Kconv::toeuc(str)
+ str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
+ decode64($1)
+ }
+ str = Kconv::toeuc(str)
str.gsub!(/\n/, ' ')
str.gsub!(/\0/, '')
- j2e(str)
+ str
end
def encode64(bin)