表单:将数据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 ?

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.

To pass data from page A to B, do you use json_encode ? This function is exclusively used for data encoded into utf-8