module Mail::Encodings

Included Modules

Extended Modules

Defined in:

mail/encodings.cr
mail/encodings/7bit.cr
mail/encodings/8bit.cr
mail/encodings/binary.cr
mail/encodings/identity.cr
mail/encodings/quoted_printable.cr
mail/encodings/transfer_encoding.cr

Class Method Summary

Class Method Detail

def self.address_encode(address, charset = "utf-8") #

[View source]
def self.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 =??B??= format

Example:

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


[View source]
def self.defined?(name) #

Is the encoding we want defined?

Example:

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


[View source]
def self.encode_non_usascii(address, charset) #

[View source]
def self.get_all #

[View source]
def self.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


[View source]
def self.get_name(name) #

[View source]
def self.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...


[View source]
def self.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"


[View source]
def self.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 =??Q??= format

Example:

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


[View source]
def self.register(name, cls) #

Register transfer encoding

Example

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


[View source]
def self.transcode_charset(str, from_charset, to_charset = "UTF-8") #

[View source]