module Mail::Encodings
Included Modules
Extended Modules
Defined in:
mail/encodings.crmail/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
- .address_encode(address, charset = "utf-8")
-
.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 -
.defined?(name)
Is the encoding we want defined?
- .encode_non_usascii(address, charset)
- .get_all
-
.get_encoding(name)
Gets a defined encoding type, QuotedPrintable or Base64 for now.
- .get_name(name)
-
.param_decode(str, encoding)
Decodes a parameter value using URI Escaping.
-
.param_encode(str)
Encodes a parameter value using URI Escaping, note the language field 'en' can be set using Mail::Configuration, like so:
-
.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 -
.register(name, cls)
Register transfer encoding
- .transcode_charset(str, from_charset, to_charset = "UTF-8")
Class Method Detail
Encode a string with Base64 Encoding and returns it ready to be inserted
as a value for a field, that is, in the =?
Example:
Encodings.b_value_encode('This is あ string', 'UTF-8') #=> "=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?="
Is the encoding we want defined?
Example:
Encodings.defined?(:base64) #=> true
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
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...
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"
Encode a string with Quoted-Printable Encoding and returns it ready to be inserted
as a value for a field, that is, in the =?
Example:
Encodings.q_value_encode('This is あ string', 'UTF-8') #=> "=?UTF-8?Q?This_is_=E3=81=82_string?="
Register transfer encoding
Example
Encodings.register "base64", Mail::Encodings::Base64