API15

JString/transcode

From Joomla! Documentation

< API15:JString

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Transcode a string.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

transcode($source, $from_encoding, $to_encoding)
Parameter Name Default Value Description
$source $source The string to transcode.
$from_encoding $from_encoding The source encoding.
$to_encoding $to_encoding The target encoding.

Returns[edit]

string Transcoded string

Defined in[edit]

libraries/joomla/utilities/string.php

Importing[edit]

jimport( 'joomla.utilities.string' );

Source Body[edit]

function transcode($source, $from_encoding, $to_encoding) {

        if (is_string($source)) {
                /*
                 * "//TRANSLIT" is appendd to the $to_encoding to ensure that when iconv comes
                 * across a character that cannot be represented in the target charset, it can
                 * be approximated through one or several similarly looking characters.
                 */
                return iconv($from_encoding, $to_encoding.'//TRANSLIT', $source);
        }
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]