SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from OpenSuSE perl-Text-Iconv-1.7-lp151.8.2.x86_64.rpm

Iconv

Section: User Contributed Perl Documentation (3)
Updated: 2011-11-18
Index 

NAME

Text::Iconv - Perl interface to iconv() codeset conversion function 

SYNOPSIS

  use Text::Iconv;  $converter = Text::Iconv->new("fromcode", "tocode");  $converted = $converter->convert("Text to convert");
 

DESCRIPTION

The Text::Iconv module provides a Perl interface to the iconv()function as defined by the Single UNIX Specification.

The convert() method converts the encoding of characters in the inputstring from the fromcode codeset to the tocode codeset, andreturns the result.

Settings of fromcode and tocode and their permitted combinationsare implementation-dependent. Valid values are specified in thesystem documentation; the iconv(1) utility should also provide a -loption that lists all supported codesets. 

Utility methods

Text::Iconv objects also provide the following methods:

retval() returns the return value of the underlying iconv() functionfor the last conversion; according to the Single UNIX Specification,this value indicates ``the number of non-identical conversionsperformed.'' Note, however, that iconv implementations vary widely inthe interpretation of this specification.

This method can be called after calling convert(), e.g.:

  $result = $converter->convert("lorem ipsum dolor sit amet");  $retval = $converter->retval;

When called before the first call to convert(), or if an error occuredduring the conversion, retval() returns undef.

get_attr(): This method is only available with GNU libiconv, otherwiseit throws an exception. The get_attr() method allows you to queryvarious attributes which influence the behavior of convert(). Thecurrently supported attributes are trivialp, transliterate, anddiscard_ilseq, e.g.:

  $state = $converter->get_attr("transliterate");

See iconvctl(3) for details. To ensure portability to other iconvimplementations you should first check for the availability of thismethod using eval {}, e.g.:

    eval { $conv->get_attr("trivialp") };    if ($@)    {      # get_attr() is not available    }    else    {      # get_attr() is available    }

This method should be considered experimental.

set_attr(): This method is only available with GNU libiconv, otherwiseit throws an exception. The set_attr() method allows you to setvarious attributes which influence the behavior of convert(). Thecurrently supported attributes are transliterate anddiscard_ilseq, e.g.:

  $state = $converter->set_attr("transliterate");

See iconvctl(3) for details. To ensure portability to other iconvimplementations you should first check for the availability of thismethod using eval {}, cf. the description of set_attr() above.

This method should be considered experimental. 

ERRORS

If the conversion can't be initialized an exception is raised (usingcroak()). 

Handling of conversion errors

Text::Iconv provides a class attribute raise_error and acorresponding class method for setting and getting its value. Thehandling of errors during conversion depends on the setting of thisattribute. If raise_error is set to a true value, an exception israised; otherwise, the convert() method only returns undef. Bydefault raise_error is false. Example usage:

  Text::Iconv->raise_error(1);     # Conversion errors raise exceptions  Text::Iconv->raise_error(0);     # Conversion errors return undef  $a = Text::Iconv->raise_error(); # Get current setting
 

Per-object handling of conversion errors

As an experimental feature, Text::Iconv also provides an instanceattribute raise_error and a corresponding method for setting andgetting its value. If raise_error is undef, the class-widesettings apply. If raise_error is 1 or 0 (true or false), theobject settings override the class-wide settings.

Consult iconv(3) for details on errors that might occur. 

Conversion of undef

Converting undef, e.g.,

  $converted = $converter->convert(undef);

always returns undef. This is not considered an error. 

NOTES

The supported codesets, their names, the supported conversions, andthe quality of the conversions are all system-dependent. 

AUTHOR

Michael Piotrowski <mxpAATTdynalabs.de> 

SEE ALSO

iconv(1), iconv(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
Utility methods
ERRORS
Handling of conversion errors
Per-object handling of conversion errors
Conversion of undef
NOTES
AUTHOR
SEE ALSO

This document was created byman2html,using the manual pages.