Unicode Функции
PHP Manual

unicode_encode

(PHP 6 >= 6.0.0)

unicode_encodeConvert a unicode string in any encoding

Описание

string unicode_encode ( unicode $input , string $encoding [, int $errmode ] )

Takes a unicode string and converts it to a string in the specified encoding .

Параметри

input

The unicode string that is converted.

encoding

The new encoding for input .

errmode

Conversion error mode. This parameter determines the action to take when the converter cannot convert a character. For a list of available modes, refer to unicode_set_error_mode(). If the parameter is not set, the global error mode is used.

Връщани стойности

A string on success, or FALSE on failure.

Грешки/Изключения

Emits a E_WARNING level error if a converter cannot be created for the desired encoding .

Примери

Example #1 A unicode_encode() example

Note: The characters will be seen instead of entities in the output.

<?php
header 
('Content-Type: text/plain; charset=ISO-8859-2');

$encoded unicode_encode ('\u0150\u0179''ISO-8859-2');

echo 
'The string itself:'$encodedPHP_EOL;
echo 
'The length of the string: 'strlen ($encoded);
?>

Примерът по-горе ще изведе нещо подобно на:

The string itself: &#336;&#377;
The length of the string: 2

Бележки

Предупреждение

Тази функция е ЕКСПЕРИМЕНТАЛНА. Поведението на функцията, името й, както и съпътстващата документация, могат да бъдат променени без предупреждение в бъдеща версия на PHP. Тази функция би трябвало да бъде използвана единствено на ваша собствена отговорност.

Вж. също


Unicode Функции
PHP Manual