API15

API15:JString/transcode

From Joomla! Documentation

Revision as of 22:26, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Transcode a string. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Transcode a string.

[Edit Descripton]

Template:Description:JString/transcode

Syntax

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

string Transcoded string

Defined in

libraries/joomla/utilities/string.php

Importing

jimport( 'joomla.utilities.string' );

Source Body

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);
        }
}

[Edit See Also] Template:SeeAlso:JString/transcode

Examples

<CodeExamplesForm />