Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/177847-solved-the-charset-is-killing-me/
Share on other sites

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.

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'");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.