In a utf8-clean environment, you have to take some actions to ensure good exchanges with other parts of you information system (eg. STDOUT, or a mysql database). Below is summary:
In a utf8-clean environment, you still need both of these:
> 1"
$ perl -C
The -C option is required to make perl globally assume UTF-8 on STDIN and provide it on STDOUT. Perhaps more convenient then setting the -C option, is defining the corresponding enviroment variable, here's an example of /etc/environment:
LANG="C" LC_ALL="sv_SE.utf8" PERL_UNICODE=""
http://perldoc.perl.org/perlrun.html#ENVIRONMENT
Q: What good does "mysql_enable_utf8 > 1" bring me?
A: It makes it possible for perl (from dbd::mysql version 4.001 and higher) to communicate with a mysql-database which uses utf8 and non-ascii characters **in column or table names**
<pre class
"example">
$dbh = DBI->connect($dsn, $username, $password, {mysql_enable_utf8 => 1}) || die "Could not connect to $database: $DBI::errstr";
$sth = $dbh->prepare("select kön from Kön where id = '1'") || die "Could not prepare statement: ".$dbh->errstr."\n";
It should also mark incomming UTF-8 data retreived from mysql as utf8 for perl internally, but does not due to a bug in libdbd-mysql-perl.
Using perl -C is a workaround for this.
To convert data to and from utf8:
use Encode;
Even if you have a utf8-only system, you need Encode if data from external sources are not utf8 encoded.
Only needed when you want variable names with utf8 characters, eg
my $förälder = "foo"; print $förälder;