Re: utf-8 in $_POST

From: Date: Mon, 07 Jan 2008 19:01:57 +0000
Subject: Re: utf-8 in $_POST
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-266852@lists.php.net to get a copy of this message
i specify iso-8859-1 in both header and body: <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"/> <form action="/" method="post" accept-charset="iso-8859-1"> if two different people post the norwegian phrase "Godt nytt år" (happy new year), it may appear in the following variations: [CONTENT_TYPE] => application/x-www-form-urlencoded;charset=iso-8859-1 $_POST["input"] = "Godt nytt år" [CONTENT_TYPE] => application/x-www-form-urlencoded;charset=utf-8 $_POST["input"] = "Godt nytt Ã¥r" i was just wondering if php had some setting or function that would make it auto-convert $_POST data into one specific encoding. otherwise i seem forced to do something like this in the beginning of my php script: if(ereg("utf-8", $_SERVER["CONTENT_TYPE"])) { foreach($_POST as $key => $value) $_POST["key"] = convert_utf8_to_iso8859($value); }

« previous php.general (#266852) next »