role Encoding

...

role Encoding { ... }

The Encoding role is implemented by objects that provide a character encoding, such as ASCII or UTF-8. Besides being implemented 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.

Methods

method name

method name(Encoding:D: --> Str)

Gets the primary name of the encoding.

method alternative-names

method alternative-names(Encoding:D: --> List)

Gets a list of alternative names for the encoding.

method decoder

method decoder(Encoding:D: *%options --> Encoding::Decoder)

Gets 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 \r\n into \n while decoding.

method encoder

method encoder(Encoding:D: *%options --> 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 True, turns \n into \r\n if the current platform is Windows).