0

I have a swedish website, and whenever I write åäö in the code, it displays as åäö on the site, but when I enter åäö in the database (for exemple a text in the column 'description'), it outputs a square with a question mark on the website.

I have tried the

<meta http-equiv="content-type" content="text/html" charset="UTF8" />

And

<?php header("Content-type: text/html; charset=utf-8");?>

And

SET NAMES 'utf8'

And all possible charsets (it feels like) but it doesn't work.

The MySQL connection collation is utf8_bin and the collation for the table column is utf8_swedish_ci. Help?

EDIT: If I edit the php.ini-file to have

default_charset = "utf8_unicode_ci"

and change the meta to

<meta http-equiv="content-type" content="text/html" charset="UTF-8_general_ci" />

the åäö displays correctly, but the åäö from the code in the files display as ä.

EDIT2: Well, the mysqli_set_charset($connection, 'utf8'); solved my problem.

user2880093
  • 31
  • 1
  • 6

1 Answers1

0
  1. <meta http-equiv="content-type" content="text/html" charset="UTF8" /> is wrong. Should be UTF-8.

  2. Don't use set names. Use mysql_set_charset('utf8',$db); instead.

  3. Check if your table has proper encoding.

  4. Check if your source code file is UTF-8 encoded.

PS. Please note that collation is not the same thing as encoding. You need to set table encoding, not collation. Collation has nothing to do with proper output encoding.

Flash Thunder
  • 11,672
  • 8
  • 47
  • 91
  • 1. Still doesn't work 2. (Doesn't get it to work) 3. All the tables have collation utf8_general_ci 4. The source code file is UTF-8 (Added a edit to the question) – user2880093 Oct 27 '13 at 02:04
  • Please note that collation is not the same thing as encoding. You need to set table encoding, not collation. Collation has nothing to do with proper output. – Flash Thunder Oct 27 '13 at 02:06