Skip Menu |
 

This queue is for tickets about the Config-Tiny CPAN distribution.

Report information
The Basics
Id: 85571
Status: resolved
Priority: 0/
Queue: Config-Tiny

People
Owner: Nobody in particular
Requestors: wolfgang.husmann [...] uni-mainz.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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>
Download (untitled) / with headers
text/plain 975b
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
Download (untitled) / with headers
text/plain 141b
Wouldn't it make more sense to allow full PerlIO strings as the second parameter? Config::Tiny->read('file.ini', ':encoding(utf8-strict)');
From: victor [...] vsespb.ru
Download (untitled) / with headers
text/plain 1.4k
Show quoted text
> use v5.12; use feature qw( unicode_strings );
So you want to set 5.12 as min version of perl? I don't think there is a good reason to do that - unicode works fine in 5.8.8+ Also seems patch is just broken, \s in regexps will match NON-BREAKING-SPACE and other unicode "space" characters. On Thu May 23 14:25:47 2013, wolfgang.husmann@uni-mainz.de wrote: Show quoted text
> 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 >
Download (untitled) / with headers
text/plain 236b
Yet another alternative would be to allow the argument to the read and write methods to be either a filename OR a filehandle. That way, people needing particular IO layers can call `open` themselves and pass the handle to Config::Tiny.
Thanx for the ideas. V 2.15 supports and encoding parameter read_file() and write_file().


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.