NAME

   Encode::Simple - Encode and decode text, simply

SYNOPSIS

     use Encode::Simple qw(encode encode_lax encode_utf8 decode decode_lax decode_utf8);
     my $bytes = encode 'Shift_JIS', $characters;
     my $bytes = encode_lax 'ASCII', $characters;
     my $bytes = encode_utf8 $characters;
     my $characters = decode 'cp1252', $bytes;
     my $characters = decode_lax 'UTF-8', $bytes;
     my $characters = decode_utf8 $bytes;

DESCRIPTION

   This module is a simple wrapper around Encode that presents "encode"
   and "decode" functions with straightforward behavior and error
   handling. See Encode::Supported for a list of supported encodings.

FUNCTIONS

   All functions are exported by name, as well as via the tags :all,
   :strict, :lax, and :utf8. By default, "encode", "encode_utf8",
   "decode", and "decode_utf8" are exported as in Encode.

encode

     my $bytes = encode $encoding, $characters;

   Encodes the input string of characters into a byte string using
   $encoding. Throws an exception if the input string contains characters
   that are not valid or possible to represent in $encoding.

encode_lax

     my $bytes = encode_lax $encoding, $characters;

   Encodes the input string of characters into a byte string using
   $encoding, encoding any invalid characters as a substitution character
   (the substitution character used depends on the encoding). Note that
   some encoders do not respect this option and may throw an exception
   anyway, this notably includes Encode::Unicode (but not UTF-8).

encode_utf8

     my $bytes = encode_utf8 $characters;

   Encodes the input string of characters into a UTF-8 byte string. Throws
   an exception if the input string contains characters that are not valid
   or possible to represent in UTF-8.

   This function will use the more consistent and efficient "encode_utf8"
   in Unicode::UTF8 if installed, and is otherwise equivalent to "encode"
   with an encoding of UTF-8.

encode_utf8_lax

     my $bytes = encode_utf8_lax $characters;

   Encodes the input string of characters into a UTF-8 byte string,
   encoding any invalid characters as the Unicode replacement character
   U+FFFD, represented in UTF-8 as the three bytes 0xEFBFBD.

   This function will use the more consistent and efficient "encode_utf8"
   in Unicode::UTF8 if installed, and is otherwise equivalent to
   "encode_lax" with an encoding of UTF-8.

decode

     my $characters = decode $encoding, $bytes;

   Decodes the input byte string into a string of characters using
   $encoding. Throws an exception if the input bytes are not valid for
   $encoding.

decode_lax

     my $characters = decode_lax $encoding, $bytes;

   Decodes the input byte string into a string of characters using
   $encoding, decoding any malformed bytes to the Unicode replacement
   character (U+FFFD). Note that some encoders do not respect this option
   and may throw an exception anyway, this notably includes
   Encode::Unicode (but not UTF-8).

decode_utf8

     my $characters = decode_utf8 $bytes;

   Decodes the input UTF-8 byte string into a string of characters. Throws
   an exception if the input bytes are not valid for UTF-8.

   This function will use the more consistent and efficient "decode_utf8"
   in Unicode::UTF8 if installed, and is otherwise equivalent to "decode"
   with an encoding of UTF-8.

decode_utf8_lax

     my $characters = decode_utf8_lax $bytes;

   Decodes the input UTF-8 byte string into a string of characters,
   decoding any malformed bytes to the Unicode replacement character
   U+FFFD.

   This function will use the more consistent and efficient "decode_utf8"
   in Unicode::UTF8 if installed, and is otherwise equivalent to
   "decode_lax" with an encoding of UTF-8.

BUGS

   Report any issues on the public bugtracker.

AUTHOR

   Dan Book <[email protected]>

COPYRIGHT AND LICENSE

   This software is Copyright (c) 2018 by Dan Book.

   This is free software, licensed under:

     The Artistic License 2.0 (GPL Compatible)

SEE ALSO

   Unicode::UTF8