Documentation

ConvertCharset

string
 CMain::ConvertCharset(
 string,
 string charset_in,
 string charset_out
);

The method is used to convert strings with different encodings. Non-static method.

Note: this method is a wrapper - for the iconv. If the iconv is unavailable, the method is used without it (with reduced performance).

Parameters

Parameter Description
string String to be converted
charset_in Initial encoding
charset_out Final encoding

Returned value

Returns the string in the required encoding.

Examples of use

Converting the $str string from Unicode into cp1251.

$str = $APPLICATION->ConvertCharset($str, "Unicode", "windows-1251");
Similar execution:
$str = iconv('CP1251', 'UTF-8', $str);


© «Bitrix24», 2001-2024
Up