$Id: encoding.txt 1759 2008-01-28 22:56:08Z mjs $ HOW TO ENCODE/DECODE VARIOUS STRINGS HTML (NAMED) ENTITIES PHP htmlentities($s, ENT_QUOTES, $input_charset) html_entity_decode($s, ENT_QUOTES, $output_charset) XML (NUMERIC) ENTITIES PHP ? If you can get away with UTF-8, though, you can use html_entity_decode() as above. URI Perl use URI::Escape; uri_escape($s); uri_unescape($s); PHP urlencode($s); urldecode($s); Javascript encodeURI(s); // does not encode question mark (?) decodeURI(s); // does not encode question mark (?) encodeURIComponent(s); // encodes question mark (?) decodeURIComponent(s); // encodes question mark (?) escape(s); // deprecated unescape(s); // deprecated MIME/EMAIL HEADERS (RFC 2047) Perl use MIME::WordDecoder; unmime($s); // decodes to iso-8859 Python http://docs.python.org/lib/module-email.header.html python >>> from email.header import decode_header >>> decode_header('=?iso-8859-1?q?p=F6stal?=') [('p\xf6stal', 'iso-8859-1')] PHP iconv_mime_encode() iconv_mime_decode() MIME BODY PUNYCODE (DOMAIN NAMES)