mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	 210367ec88
			
		
	
	
		210367ec88
		
	
	
	
	
		
			
			which included commits to RCS files with non-trunk default branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			472 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			472 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require "kconv"
 | |
| 
 | |
| def decode64(str)
 | |
|   str.unpack("m")[0]
 | |
| 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/, '')
 | |
|   str
 | |
| end
 | |
| 
 | |
| def encode64(bin)
 | |
|   [bin].pack("m")
 | |
| end
 | |
| 
 | |
| def b64encode(bin, len = 60)
 | |
|   encode64(bin).scan(/.{1,#{len}}/o) do
 | |
|     print $&, "\n"
 | |
|   end
 | |
| end 
 |