PYTHON iconv

is this article helpful?
Python replacement for PHP's iconv [ edit | history ]
>>> print "Hello, World!".encode('rot13')
"Uryyb, Jbeyq!"

A full list of encodings are available at:

PHP iconv

PHP original manual for iconv [ show | ]


(PHP 4 >= 4.0.5, PHP 5)

iconvConvert string to requested character encoding


string iconv ( string $in_charset , string $out_charset , string $str )

Performs a character set conversion on the string str from in_charset to out_charset .



The input charset.


The output charset.

If you append the string //TRANSLIT to out_charset transliteration is activated. This means that when a character can't be represented in the target charset, it can be approximated through one or several similarly looking characters. If you append the string //IGNORE, characters that cannot be represented in the target charset are silently discarded. Otherwise, str is cut from the first illegal character.


The string to be converted.

Return Values

Returns the converted string or FALSE on failure.


Example #1 iconv() example

echo iconv("ISO-8859-1""UTF-8""This is a test.");