Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>So what's the problem,</p> </blockquote> <p>It's a <code>’</code> (<a href="http://www.fileformat.info/info/unicode/char/2019/index.htm" rel="noreferrer"><code>RIGHT SINGLE QUOTATION MARK</code></a> - U+2019) character which has been encoded as <a href="http://en.wikipedia.org/wiki/Windows-1252" rel="noreferrer">CP-1252</a> instead of <a href="http://en.wikipedia.org/wiki/UTF-8" rel="noreferrer">UTF-8</a>. If you check the <a href="http://www.fileformat.info/info/unicode/char/2019/index.htm" rel="noreferrer">encodings</a> table, then you see that this character is in UTF-8 composed of bytes <code>0xE2</code>, <code>0x80</code> and <code>0x99</code>. If you check the <a href="https://en.wikipedia.org/wiki/Windows-1252#Code_page_layout" rel="noreferrer">CP-1252 code page layout</a>, then you'll see that each of those bytes stand for the individual characters <code>â</code>, <code>€</code> and <code>™</code>.</p> <hr> <blockquote> <p>and how can I fix it?</p> </blockquote> <p>Use UTF-8 instead of CP-1252 to read, write, store, and display the characters.</p> <hr> <blockquote> <p>I have the Content-Type set to UTF-8 in both my <code>&lt;head&gt;</code> tag and my HTTP headers:</p> <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; </code></pre> </blockquote> <p>This only instructs the client which encoding to use to interpret and display the characters. This doesn't instruct your own program which encoding to use to read, write, store, and display the characters in. The exact answer depends on the server side platform / database / programming language used. Do note that the one set in HTTP response header has precedence over the HTML meta tag. The HTML meta tag would only be used when the page is opened from local disk file system instead of from HTTP.</p> <hr> <blockquote> <p>In addition, my browser is set to <code>Unicode (UTF-8)</code>:</p> </blockquote> <p>This only forces the client which encoding to use to interpret and display the characters. But the actual problem is that you're already sending <code>’</code> (encoded in UTF-8) to the client instead of <code>’</code>. The client is correctly displaying <code>’</code> using the UTF-8 encoding. If the client was misinstructed to use, for example ISO-8859-1, you would likely have seen <code>ââ¬â¢</code> instead.</p> <hr> <blockquote> <p>I am using ASP.NET 2.0 with a database.</p> </blockquote> <p>This is most likely where your problem lies. You need to verify with an independent database tool what the data looks like.</p> <p>If the <code>’</code> character is there, then you aren't connecting to the database correctly. You need to tell the database connector to use UTF-8.</p> <p>If your database contains <code>’</code>, then it's your database that's messed up. Most probably the tables aren't configured to use <code>UTF-8</code>. Instead, they use the database's default encoding, which varies depending on the configuration. If this is your issue, then usually just altering the table to use UTF-8 is sufficient. If your database doesn't support that, you'll need to recreate the tables. It is good practice to set the encoding of the table when you create it.</p> <p>You're most likely using SQL Server, but here is some MySQL code (copied from <a href="http://balusc.omnifaces.org/2009/05/unicode-how-to-get-characters-right.html#Databases" rel="noreferrer">this article</a>):</p> <pre><code>CREATE DATABASE db_name CHARACTER SET utf8; CREATE TABLE tbl_name (...) CHARACTER SET utf8; </code></pre> <p>If your table is however already UTF-8, then you need to take a step back. <em>Who</em> or <em>what</em> put the data there. <em>That's</em> where the problem is. One example would be HTML form submitted values which are incorrectly encoded/decoded.</p> <hr> <p>Here are some more links to learn more about the problem: </p> <ul> <li><a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="noreferrer">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)</a>, from our own Joel.</li> <li><a href="http://balusc.omnifaces.org/2009/05/unicode-how-to-get-characters-right.html" rel="noreferrer">Unicode - How to get the characters right?</a>, with more concise and practical information, solutions are targeted on Java environments.</li> <li><a href="https://allseeing-i.com/How-to-setup-your-PHP-site-to-use-UTF8" rel="noreferrer">How to setup your PHP site to use UTF8</a>, targeted on PHP environments.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload