Jump to content

Language display problem


geroid

Recommended Posts

I've just been looking at an Irish language site and cut some text out to go on my webpage. However, the text was not displayed properly. If you look at the example below, you will see that in many irish words we have a symbol above the letter as follows:

 

dé Céadaoin

 

In the case of the above example, the browser replaces the e in de and the e in Ceadaoin with a symbol that looks like a small square. However these display correctly in the original site where I copied from. What do I need to do to get a proper display of these characters.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/153841-language-display-problem/
Share on other sites

It's a charset encoding issue.

 

You will have to look at which encoding you save the file, the database data if any, the http header and the meta in the (x)html file.

 

There is some editor and tool that allow you to save the file in different encoding you can take a look at this : http://en.wikipedia.org/wiki/Character_encoding

 

You can setup the charset in mysql connection with this (be sure to change row to the proper charset encoding first) :

<?php
mysql_query("SET NAMES 'utf8';", $connect) or die ("Unable to set names.");
mysql_query("SET CHARACTER SET 'utf8';", $connect) or die ("Unable to set charset.");
?>

 

You can set the charset in http header for html with this (for xhtml it can be a lot more complicated that this though i think most people serve/view xhtml as text/html) :

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

 

And in html/head with this :

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

 

Use utf8 (unicode) or change it to whatever encoding type you want.

 

You can use http://www.php.net/manual/en/function.htmlentities.php to convert special charaters into a ASCII readable entities which will work no matter what charset you have.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.