Weird characters on my site

Every once in a while I get a submission to Song Key Finder that contains some weird characters (they showed up as boxes). I use the MusicBrainz database api to verify song and artist information, so my first thought was to consult with them. Since the characters appeared to be showing up in non-english songs, I looked into their international information:

MusicBrainz uses UTF-8 for all its data, which means that all the data is stored in Unicode and supports lots of different languages.

Got it. So now that I know their info is in UTF-8 I needed to make sure my page was being interpreted with that. Smashing Magazine provided a great article about character encodings which explains everything!

All the encoding problems…are caused by text being submitted in one character set and viewed in another. The solution is to make sure that every page on your website uses UTF-8. You can do this with one of these lines immediately after the <head> tag:

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

It has to be one of the first things in your Web page, as it will cause the browser to look again at the page in a whole new light. For speed and efficiency, it should do this as soon as possible.

So all I had to do was just add this as the first line to the head, and all the weird characters started showing up normally (most were accented a’s and e’s)!

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


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *