From: <mp...@kr...> - 2007-09-28 21:41:47
|
Revision: 4127 Author: mpeters Date: 2007-09-28 17:41:30 -0400 (Fri, 28 Sep 2007) Log Message: ----------- we cant munge this in BEGIN since it needs to change per-instance Modified Paths: -------------- trunk/krang/lib/Krang/Charset.pm Modified: trunk/krang/lib/Krang/Charset.pm =================================================================== --- trunk/krang/lib/Krang/Charset.pm 2007-09-28 21:41:11 UTC (rev 4126) +++ trunk/krang/lib/Krang/Charset.pm 2007-09-28 21:41:30 UTC (rev 4127) @@ -1,9 +1,9 @@ package Krang::Charset; -use Krang::ClassFactory qw(pkg); use strict; use warnings; -use Krang::ClassLoader Conf => qw(Charset); +use Krang::ClassLoader 'Conf'; +use Krang::ClassFactory qw(pkg); =head1 NAME @@ -35,21 +35,18 @@ =cut -my $MUNGED; sub _munge_charset { my $charset = lc shift; $charset =~ s/\s*//; # remove ws $charset =~ s/-//; # remove hyphens return $charset; } -BEGIN { - $MUNGED = _munge_charset(Charset()); -} sub is_utf8 { my ($class, $charset ) = @_; - return ( $charset ? _munge_charset($charset) : $MUNGED ) eq 'utf8'; + $charset ||= pkg('Conf')->get('Charset') || ''; + return _munge_charset($charset) eq 'utf8'; } =head2 C<< Krang::Charset->mysql_charset([$charset]) @@ -69,9 +66,11 @@ cp1252 => 'latin1', windows1252 => 'latin1', ); + sub mysql_charset { my ($pkg, $charset) = @_; - $charset = $charset ? _munge_charset($charset) : $MUNGED; + $charset ||= pkg('Conf')->get('Charset') || ''; + $charset = _munge_charset($charset); return $MYSQL_MAP{$charset} || $charset; } |