Encoding role is implemented by classes that provide a character encoding, such as ASCII or UTF-8. Besides being used by the built-in character encodings, it may also be implemented by users to provide new encodings. Instances of objects doing this role are typically obtained using Encoding::Registry. For a list of supported encodings, see IO::Handle.
All methods provided by this role are stubs; they should be implemented by consumers of the role.
method name(--> Str)
Abstract method that would return the primary name of the encoding.
Abstract methods that should get a list of alternative names for the encoding.
method decoder(* --> Encoding::Decoder)
Should get a character decoder instance for this encoding, configured with the provided options. Options vary by encoding. The built-in encodings all support
translate-nl, which if
True will translate
\n while decoding.
method encoder(* --> Encoding::Encoder)
Gets a character encoder instance for this encoding, configured with the provided options. Options vary by encoding. The built-in encodings all support both
replacement (either a
Str replacement sequence or
True to use a default replacement sequence for unencodable characters) and
translate-nl (when set to
\r\n if the current platform is Windows).