0

I have a problem with my encoding when using forms. Form end up in undecoded UTF-8 text like "\xd0\xb0" for example is utf-8 Cyrillic "a".

The page has encoding set to UTF-8, the files are also UTF-8 without BOM and PHP also has mb_internal_encoding set to UTF-8. Still, i get unencoded text when printing $_POST["field"].

The form has the following params:

<form action="/User/AddDatabase/" method="POST" accept-charset="UTF-8">

This returns \xd0\xb0 when "a" is submited:

<input type="text" placeholder="Име" name="Name" '.(isset($_POST["Name"]) ? 'value="'.$_POST["Name"].'"' : '').' />

This returns the same as inputed:

<input type="text" placeholder="Име" name="Name" '.(isset($_POST["Name"]) ? 'value="'.utf8_decode($_POST["Name"]).'"' : '').' />

Is there a way to make this work without using utf8_decode function?

Andrey Tsarev
  • 769
  • 1
  • 8
  • 25
  • 1
    Not as far as I know.... – Ad5001 Feb 16 '17 at 21:39
  • Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – miken32 Feb 16 '17 at 21:43
  • It's not, since I've done all the things listed there. Not counting Data Storage and Data Access though, because I get wrong encoding even before that. I am unable to find where the problem happens – Andrey Tsarev Feb 16 '17 at 21:51
  • Something wrong with your php-configuration. Can you try to run your code on another system and compare results? – Ans Feb 17 '17 at 06:24

0 Answers0