Re: utf-8 in $_POST

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Olav Mørkrid wrote:
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"

Hm... What User Agents? Are there User Agents that do not follow the instructions?

i was just wondering if php had some setting or function that would
make it auto-convert $_POST data into one specific encoding.

I have been banging my head over this some time ago. The main problem I had at that time is that I could not find a reliable way to detect the incoming encoding, which is the base of conversion.

If the User Agents are so unstable, you can't expect consistent error, but you should be prepared for all kind of deviations.

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);
}

As said above, you assume that the inconsistency will persist. And this assumption is not stable, as it seems the User Agents do not follow the instructions you sent to them.

I would agree with the others and advice you to switch to UTF-8 - this is the only encoding, where you can handle multiple alphabets _without_ knowing which alphabet it is.

Iv

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux