duanqing2209 2013-06-05 12:48
浏览 92

表单:将数据UTF8传递到另一个页面

I'm posting ($_POST[]) data from page A and try to output it on page B, however something isn't working with UTF8.

The data on page B is (I believe) not in UTF8, for example é becomes ?. If I use utf8_encode on page B it's all fine again.

The tricky part is that mb_detect_encoding() does return UTF-8on page B for the data from POST

So on page A I have all headers set to UTF8

header("Content-Type: text/html; charset=utf-8");
<meta charset="utf-8">

And after my mysql connection

mysqli_set_charset($mysqli, "utf8");

The form on page A has

accept-charset="UTF-8"

and page B is loaded with Ajax and has also the header on

Am I missing something? Or should I always use utf8_encode() on data from POST ?

  • 写回答

2条回答 默认 最新

  • dongzi9196 2013-06-05 12:52
    关注

    You can add the code accept-charset="UTF-8" in Config page itself. So it will be used in all pages as you need that.

    评论

报告相同问题?