iconv
iconv
Convert a string from one character encoding to another
**iconv** string $from_encoding string $to_encoding string $string
Converts from
to .
string``from_encoding``to_encoding
from_encoding
The current encoding used to interpret .
string
to_encodingThe desired encoding of the result.
If the string is appended to
, 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 is appended,
characters that cannot be represented in the target charset are silently
discarded. Otherwise, is generated and the function
will return false.
`//TRANSLIT``to_encoding``//IGNORE``E_NOTICE`
Let op: > If and how works exactly depends on the system's iconv() implementation (cf. ). Some implementations are known to ignore , so the conversion is likely to fail for characters which are illegal for the .
//TRANSLIT``ICONV_IMPL``//TRANSLIT``to_encoding
stringThe string to be converted.
Returns the converted string,return.falseforfailure.
Voorbeeld: example
<?php
$text = "This is the Euro symbol '€'.";
echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;
?>
Original : This is the Euro symbol '€'.
TRANSLIT : This is the Euro symbol 'EUR'.
IGNORE : This is the Euro symbol ''.
Plain :
Notice: iconv(): Detected an illegal character in input string in .\iconv-example.php on line 7
Opmerking: > The character encodings and options available depend on the installed implementation of iconv. If the argument to or is not supported on the current system, false will be returned.
from_encoding``to_encoding
mb_convert_encoding``UConverter::transcode