UTF8编码/€[重复]

This question already has an answer here:

I have a problem displaying "€" in my html...

  1. My database field has collation "utf8_general_ci"
  2. I fetch the data like that into an javascript variable:

    $query = mysqli_query($con, "SELECT * FROM Table WHERE Id = '1'"); $data = mysqli_fetch_assoc($query);

    $data = json_encode(utf8_encode(($data["Field"])));
    

As I want to echo $data... I get Umlauts see "ÄüÖü" and other chars like " ', #@&" etc. BUT I DON'T SEE THE SIGN..... it get's displayed as a ? ( Not that in a rectangle... just a normal ?)

Can anyone help please?

Btw, that's my header:

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

s encoded UTF-8. You should have an option to that effect in your editor's or IDE's "Save as" dialog.

Then make sure your connection is UTF-8 encoded as well - it is ISO-8859-1 by default.

After connecting to the database, for mySQL before 5.0.7:

mysql_query("SET NAMES utf8"); For mySQL 5.0.7 and newer:

mysql_set_charset("utf8");