NAME

Krang::Charset - some handy utility methods for dealing with character sets


SYNOPSIS

    pkg('Charset')->is_utf8(); # depends on krang.conf
    pkg('Charset')->is_utf8('ISO 8859-1');  # false
    pkg('Charset')->is_utf8('UTF 8');       # true
    pkg('Charset')->is_utf8('utf-8');       # true
    # what does mysql want?
    pkg('Charset')->mysql_charset('UTF 8');         # utf8
    pkg('Charset')->mysql_charset('ISO 8859-1');    # latin1


DESCRIPTION

This class just provides a collection of methods that are useful when operating on character sets.


INTERFACE

Krang::Charset->is_utf8([$charset])

Returns true if the character set looks like UTF-8. Defaults to using the configured characters set if none is given.

Krang::Charset->mysql_charset([$charset])

This method tries to convert the given charset into something that MySQL can understand. Defaults to using the configured characters set if none is given.

Krang::Charset->is_supported($charset, [$dbh])

Returns true if the given encoding is supported by the version of Perl and MySQL installed.

Takes the Character Set to test as the first argument and an optional database handle as the second (in case we're in a situation where we can't use Krang::DB yet like during the install).