Subject: | Cofig::Tiny and Unicode |
Date: | Thu, 23 May 2013 10:25:16 +0000 |
To: | "bug-Config-Tiny [...] rt.cpan.org" <bug-Config-Tiny [...] rt.cpan.org> |
From: | "Husmann, Wolfgang" <wolfgang.husmann [...] uni-mainz.de> |
Hi,
Config::Tiny 4.59 does not handle UTF8-encoded INI-Files correctly. The
following changes in Tiny.pm should correct that (untested!):
use v5.12;
use feature qw( unicode_strings );
adding an optional second argument called $encoding to Config::Tiny->read()
open( CFG, '<' . ( defined $encoding ? "< :encoding($encoding)" : '<' ),
$file ) or return ...
adding an optional second argument called $encoding to
Config::Tiny->write()
open( CFG, ( defined $encoding ? "> :encoding($encoding)" : '>' ), $file )
or return ...
These changes should maintain some backward compatability while allowing
to read and write ini files with any encoding:
same as before:
my $configHash_ref = Config::Tiny->read('Demo4IniFile.ini');
new feature:
my $configHash_ref = Config::Tiny->read('Demo4IniFile.ini', 'iso-8859-1');
my $configHash_ref = Config::Tiny->read('Demo4IniFile.ini', 'utf8-strict');
I would volunteer as beta tester.
Regards,
Wolfgang Husmann