Kernel::System::Encode - character encodings
This module will use Perl's Encode module (Perl 5.8.0 or higher is required).
Don't use the constructor directly, use the ObjectManager instead:
my $EncodeObject = $Kernel::OM->Get('Kernel::System::Encode');
Convert a string from one charset to another charset.
my $utf8 = $EncodeObject->Convert( Text => $iso_8859_1_string, From => 'iso-8859-1', To => 'utf-8', ); my $iso_8859_1 = $EncodeObject->Convert( Text => $utf-8_string, From => 'utf-8', To => 'iso-8859-1', );
There is also a Force => 1 option if you need to force the already converted string. And Check => 1 if the string result should be checked to be a valid string (e. g. valid utf-8 string).
Convert given charset into the internal used charset (utf-8). Should be used on all I/O interfaces.
my $String = $EncodeObject->Convert2CharsetInternal( Text => $String, From => $SourceCharset, );
Convert internal used charset (e. g. utf-8) into given charset (utf-8).
Should be used on all I/O interfaces if data is already utf-8 to set the utf-8 stamp.
$EncodeObject->EncodeInput( \$String ); $EncodeObject->EncodeInput( \@Array );
Convert utf-8 to a sequence of bytes. All possible characters have a UTF-8 representation so this function cannot fail.
This should be used in for output of utf-8 chars.
$EncodeObject->EncodeOutput( \$String ); $EncodeObject->EncodeOutput( \@Array );
switch output file handle to utf-8 output.
$EncodeObject->ConfigureOutputFileHandle( FileHandle => \*STDOUT );
Checks if an encoding is a super-set of ASCII, that is, encodes the codepoints from 0 to 127 the same way as ASCII.
my $IsSuperset = $EncodeObject->EncodingIsAsciiSuperset( Encoding => 'UTF-8', );
From a list of character encodings, returns the first that is a super-set of ASCII. If none matches, ASCII
is returned.
my $Encoding = $EncodeObject->FindAsciiSupersetEncoding( Encodings => [ 'UTF-16LE', 'UTF-8' ], );
This software is part of the OTRS project (https://otrs.org/).
This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.