module

Mail::Encodings

Inherits Mail::Constants

Class methods

address_encode(address, charset = "utf-8")
Source
b_value_encode(string, encoding = nil)

Encode a string with Base64 Encoding and returns it ready to be inserted as a value for a field, that is, in the =?<charset>?B?<string>?= format

Example:

Encodings.b_value_encode('This is あ string', 'UTF-8') #=> "=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?="

Source
defined?(name)

Is the encoding we want defined?

Example:

Encodings.defined?(:base64) #=> true

Source
encode_non_usascii(address, charset)
Source
get_all
Source
get_encoding(name)

Gets a defined encoding type, QuotedPrintable or Base64 for now.

Each encoding needs to be defined as a Mail::Encodings::ClassName for this to work, allows us to add other encodings in the future.

Example:

Encodings.get_encoding(:base64) #=> Mail::Encodings::Base64

Source
get_name(name)
Source
param_decode(str, encoding)

Decodes a parameter value using URI Escaping.

Example:

Mail::Encodings.param_decode("This%20is%20fun", 'us-ascii') #=> "This is fun"

str = Mail::Encodings.param_decode("This%20is%20fun", 'iso-8559-1') str.encoding #=> 'ISO-8859-1' ## Only on Ruby 1.9 str #=> "This is fun" TODO: Add Support for metioned charsets...

Source
param_encode(str)

Encodes a parameter value using URI Escaping, note the language field 'en' can be set using Mail::Configuration, like so:

Mail.defaults do param_encode_language 'jp' end

The character set used for encoding will either be the value of $KCODE for Ruby < 1.9 or the encoding on the string passed in.

Example:

Mail::Encodings.param_encode("This is fun") #=> "us-ascii'en'This%20is%20fun"

Source
q_value_encode(encoded_str, encoding = nil)

Encode a string with Quoted-Printable Encoding and returns it ready to be inserted as a value for a field, that is, in the =?<charset>?Q?<string>?= format

Example:

Encodings.q_value_encode('This is あ string', 'UTF-8') #=> "=?UTF-8?Q?This_is_=E3=81=82_string?="

Source
register(name, cls)

Register transfer encoding

Example

Encodings.register "base64", Mail::Encodings::Base64

Source
transcode_charset(str, from_charset, to_charset = "UTF-8")
Source

Nested types