-2

I was experimenting with how special characters such as č, š and ž appear in the database, once inserted. Inserting the string "č_š_ž" looks like this in the database (varchar field): "Ä_Å¡_ž". For me it is not a problem how the string appears in the database, but as it seems it still looks like "Ä_Å¡_ž" when I fetch it back from the database and render it in HTML with this meta (if it matters):

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

I also tried real-escaping the string before inserting it, but the result stays the same. Anyone knows a good way to deal with that? Any help is greatly appreciated!

shiro
  • 914
  • 2
  • 11
  • 21

3 Answers3

1

Make your table's encoding to utf8_general_ci, this makes MySQL physically store and retrieve values encoded in UTF-8 .

And read this : Database Character Set and Collation

Alireza Fallah
  • 4,609
  • 3
  • 31
  • 57
0

Use this:

$set_utf=$dbh->exec("SET NAMES UTF8");
digitai
  • 1,870
  • 2
  • 20
  • 37
-1

make sure your characters are related to the language you are using. When i used hindi characters i used this in my :

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta http-equiv="Content-Language" content="hi" />

And also after connecting to your database add in this line of code:

mysql_query("SET NAMES UTF8");