Author image Rafaël Garcia-Suarez


encoding::source - allows you to write your script in non-ascii or non-utf8


NOTE: This module relies on the internal perl variable ${^ENCODING}, which is deprecated in perl 5.22.0. In this perl version the encoding pragma has been made lexical, which removes the usefulness of this module.


    use encoding::source 'utf8';
    no encoding::source; # back to latin-1

      use encoding::source 'utf8';
      # ...
    # back to latin-1


This pragma allows to change the default encoding for string literals in the current lexical compilation unit (block or file).

This is like the encoding pragma (pre-5.22.0), but done right:

  • It doesn't mess with the STDIN and STDOUT filehandles.

  • It's lexically scoped and its effect doesn't leak into other files.


Encode, encoding


(c) Copyright 2007 by Rafael Garcia-Suarez.

Most test files are adapted from the tests of encoding, maintained by Dan Kogai as part of the Encode distribution.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.