Encoding Reference
Support for character encodings.
What it is #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method name #
method name(--> Str)
Returns Str.
Abstract method that would return the primary name of the encoding.
method alternative-names #
method alternative-names()
Abstract methods that should get a list of alternative names for the encoding.
method decoder #
method decoder(*%options --> Encoding::Decoder)
Returns 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 \r\n into \n while decoding.
method encoder #
method encoder(*%options --> Encoding::Encoder)
Returns 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).
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
1 no-output
role Encoding { ... }Not executed: the documentation states no expected output for this example.