iconv

PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8
iconv - Convert a string from one character encoding to another

iconv( string$from_encoding, string$to_encoding, string$string ): string|false

Converts string from from_encoding to to_encoding.

Parameters

from_encoding

The current encoding used to interpret string.

to_encoding

The desired encoding of the result.

If the string //TRANSLIT is appended to to_encoding, then transliteration is activated. This means that when a character can't be represented in the target charset, it may be approximated through one or several similarly looking characters. If the string //IGNORE is appended, characters that cannot be represented in the target charset are silently discarded. Otherwise, E_NOTICE is generated and the function will return false.

Caution:

If and how //TRANSLIT works exactly depends on the system's iconv() implementation (cf. ICONV_IMPL). Some implementations are known to ignore //TRANSLIT, so the conversion is likely to fail for characters which are illegal for the to_encoding.

string

The string to be converted.

Return Values

Returns the converted string, or false on failure.

Notes

Note:

The character encodings and options available depend on the installed implementation of iconv. If the argument to from_encoding or to_encoding is not supported on the current system, false will be returned.

Related Functions

Example of iconv

Show all examples for iconv

PHP Version:


Function iconv:

iconv Functions

Most used PHP functions