Reputation: 5805
I have a problem with showing a value from mysql database. So value is saved as UTF-8 in the mysql database ( correctly ) , I am retrieving a JSON formated data to javascript (correctly) and then when I print the result in the javascript I don't see right signs as I am using Croatian alphabet.
I have put this in the head section:
<meta name="http-equiv" content="Content-type: text/html; charset=UTF-8"/>
and in the script section:
<script type="text/javascript" charset="utf-8">
What can I do next?
Upvotes: 2
Views: 13182
Reputation: 1109685
The character encoding has to be set on the real HTTP response Content-Type
header, not alone on the meta tag. The meta tag is ignored when the HTML output is retrieved by a HTTP request. In webbrowser's developer toolset as you can get by pressing F12 in Chrome/IE9/Firebug, you must be able to explore the HTTP response headers like below:
Based on the comments you're apparently using PHP to produce HTML output to the HTTP response. You should then be using its header()
function to set the proper response header. Add the following line to your PHP script before any character is been written to the response.
header("Content-Type: text/html;charset=UTF-8");
Upvotes: 1