Fred Cardoso
Fred Cardoso

Reputation: 323

UTF8 Uppercase displaying incorrectly

I have a simple problem, but I do not found any solution for this problem.

I'm using utf8_general_ci encoding in database(MySQL) and in the website is PHP.

In HTML page also using utf-8 as encoding (<meta charset="utf-8">).

The problem is that in database I have a word stored which starts with Â, after enconding it appears as à the difference is between ^ and ~. Uncoded: Â. Enconded: Ã.

The problem is that in the website appears this �? in the place of the  but if I change it for lowercase it appears normally. Only uppercase letters appear incorrectly when they have accentuation.

I hope I was clear.

Thanks.

Upvotes: 3

Views: 1924

Answers (3)

Terlan Abdullayev
Terlan Abdullayev

Reputation: 337

You just need to add lang attribute to the html tag of your web page. For example. Change the az to your language code.

    <!DOCTYPE html>
    <html lang="az">
      <head>
        <meta charset="utf-8" />
      </head>
      <body>

      </body>
    </html>

Upvotes: 1

1010
1010

Reputation: 1848

As you can see here, decoding utf-8 as windows1252 or iso-8859-1 produces  instead of Â.

and in windows1252 â has code E2 which coincides with its unicode codepoint U+00E2. that makes me think that some part of your application is correctly decoding the utf-8 string, but failing to encode it correctly.

You should check if your data is consistenly stored in utf-8 in your database, maybe you could select your varchar data as varbinary to be sure (in sqlserver you can convert to binary, in mysql I don't know if it works).

And check the source of your html output to see what bytes are you actually getting.

This is not a proper answer, but was too long for a comment...

Upvotes: 0

Zenorbi
Zenorbi

Reputation: 2634

You may also need to set the transfer character encoding for the MySQL link.

mysql_query('SET NAMES "utf8"');
mysql_query('SET CHARACTER SET utf8');
mysql_set_charset('utf8');

If this doesn't help, make sure that the server is not overwriting your <meta charset="utf-8"> via the Content-Type HTTP header. You may need to overwrite that as well using

header('Content-Type: text/html; charset=utf-8');

Upvotes: 0

Related Questions