FIXME: This class can handle only (euc-jp/shift_jis -> iso-2022-jp).
- D
- E
- H
- K
- L
- M
- N
- P
- R
- S
- T
- W
BENCODE_DEBUG | = | false unless defined?(BENCODE_DEBUG) |
SPACER | = | "\t" |
MAX_LINE_LEN | = | 70 |
OPTIONS | = | { 'EUC' => '-Ej -m0', 'SJIS' => '-Sj -m0', 'UTF8' => nil, # FIXME 'NONE' => nil } |
METHOD_ID | = | { ?jj => :extract_J, ?ee => :extract_E, ?aa => :extract_A, ?ss => :extract_S } |
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 172 def Encoder.encode( str ) e = new() e.header_body str e.terminate e.dest.string end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 189 def initialize( dest = nil, encoding = nil, eol = "\r\n", limit = nil ) @f = StrategyInterface.create_dest(dest) @opt = OPTIONS[$KCODE] @eol = eol reset end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 214 def dest @f end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 288 def encode_value( str ) str.gsub(TOKEN_UNSAFE) {|s| '%%%02x' % s[0] } end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 241 def header_body( str ) scanadd normalize_encoding(str) end
add
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 231 def header_line( line ) scanadd line end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 235 def header_name( name ) add_text name.split(%r-/).map {|i| i.capitalize }.join('-') add_text ':' add_lwsp ' ' end
FIXME: implement line folding
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 274 def kv_pair( k, v ) return if v.nil? v = normalize_encoding(v) if token_safe?(v) add_text k + '=' + v elsif not CONTROL_CHAR === v add_text k + '=' + quote_token(v) else # apply RFC2231 encoding kv = k + '*=' + "iso-2022-jp'ja'" + encode_value(v) add_text kv end end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 251 def lwsp( str ) add_lwsp str.sub(%r[\r\n]+[^\r\n]*\z/, '') end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 255 def meta( str ) add_text str end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 196 def normalize_encoding( str ) if @opt then NKF.nkf(@opt, str) else str end end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 263 def phrase( str ) str = normalize_encoding(str) if CONTROL_CHAR === str scanadd str else add_text quote_phrase(str) end end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 218 def puts( str = nil ) @f << str if str @f << @eol end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 203 def reset @text = '' @lwsp = '' @curlen = 0 end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 245 def space add_lwsp ' ' end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 209 def terminate add_lwsp '' reset end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 259 def text( str ) scanadd normalize_encoding(str) end
Source: show
# File rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb, line 223 def write( str ) @f << str end