I'm working on a multilingual site with CodeIgniter. There is a form that posts data to controller, but $_POST
is empty when I start to use Turkish characters like öçüÜĞ
etc.
I set the charset to:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Form:
<form action="translations/save" method="post" accept-charset="utf-8">
<textarea rows="6" cols="60" id="editor_tr" name="editor_tr">Türkçe</textarea>
</form>
$_POST
and $this->input->post('editor_tr')
returns empty, but I can see the raw post with file_get_contents("php://input")
.
This one works OK in a normal PHP test, but doesn't work with CodeIgniter. Perhaps my .htaccess file is causing the issue, but dunno.
Any help is much appreciated.
UPDATE: Here is the output for var_dump as requested.
var_dump($_POST)
- Without Turkish chars
array(3) { ["id"]=> string(12) "news8titleID" ["editor_tr"]=> string(13) "turkish value" ["editor_en"]=> string(13) "english value" }
var_dump($_POST)
- With Turkish chars (The input was: Türkçe karakter
, but it doesn't show up in the $_POST)
array(3) { ["id"]=> string(12) "news8titleID" ["editor_tr"]=> string(0) "" ["editor_en"]=> string(13) "english value" }
UPDATE 2:
When debugging, I have found out that system.core.Input
class cleans the input data on _clean_input_data
function.
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
So, before the $_POST
has reached to my controller, the editor_tr
value is already cleaned by system.core.Utf8
class in this function:
function clean_string($str)
{
if ($this->_is_ascii($str) === FALSE)
{
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
}
return $str;
}