Skip to content

Instantly share code, notes, and snippets.

@niczero
Created November 27, 2014 14:46
Show Gist options
  • Save niczero/af29d23d13aca1cd04ea to your computer and use it in GitHub Desktop.
Save niczero/af29d23d13aca1cd04ea to your computer and use it in GitHub Desktop.
How to handle encodings on input/output
open my $handle, '<:encoding(UTF-8)', $file;
open my $handle, '<:encoding(iso-8859-1)', $file;
open my $handle, '<', $file;
binmode $handle, ':encoding(UTF-8)';
use open ':encoding(UTF-8)';
use open ':encoding(iso-8859-1)';
use open ':locale';
use PerlIO::locale;
binmode STDOUT, ':locale';
# see http://perlgeek.de/en/article/encodings-and-unicode
# see http://www.perl.com/pub/2012/04/perlunicook-standard-preamble.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment