Bisa Posted October 15, 2009 Share Posted October 15, 2009 I've tried to make my website international (that is making it possible to post any character such as åäö) but all I am getting is cryptic symbols... Here is the deal, I thought utf-8 was the way to go so my meta tag reads as follows: <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> The default char set in my database reads " DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci" (side note, is there a choise without the collate so I only have utf8?). What I am doing is using php to fetch data from the db and store a variable that is to be printed on my page as content. If I type anything in the html using åäö they show up fine due to the meta tag BUT anything I echo such as the content variable the åäö shows up pretty screwed... --- Basically, whats "standard procedure" when storing international text into a db? Quote Link to comment https://forums.phpfreaks.com/topic/177847-solved-the-charset-is-killing-me/ Share on other sites More sharing options...
corbin Posted October 16, 2009 Share Posted October 16, 2009 The thing you have to remember about PHP and UTF-8 is that PHP pretty much sucks at handling multibyte charsets. (Which is really no fault of its own to some extent.) Are you altering the text at all or just straight up echoing it? If you're altering it first, you will need to make sure to use multibyte or binary safe functions. If not, then I'll think type out other stuff. Quote Link to comment https://forums.phpfreaks.com/topic/177847-solved-the-charset-is-killing-me/#findComment-937856 Share on other sites More sharing options...
haku Posted October 16, 2009 Share Posted October 16, 2009 If you are using php greater than 5.2.3, use this after selecting your database and table: mysql_set_charset('utf8',$connection) Where $connection is your database connection. If you are using an earlier version of php you can use this: mysql_query("SET NAMES 'utf8'"); Quote Link to comment https://forums.phpfreaks.com/topic/177847-solved-the-charset-is-killing-me/#findComment-937878 Share on other sites More sharing options...
Bisa Posted October 16, 2009 Author Share Posted October 16, 2009 ah, thank you, mysql_set_charset('utf8',$db_connect) in my configuration file did the trick =) Quote Link to comment https://forums.phpfreaks.com/topic/177847-solved-the-charset-is-killing-me/#findComment-937937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.