Saturday, July 11, 2009

Making site in some other language like hebrew

I’ve been working on a little application that grabs data from Hebrew news sites into a mySQL database.

While working on this mini-project I’ve realized that there is hardly any online tutorials on using the Hebrew font. Here’s my solution which is fairly simple and works effectively.

Step 1) Set the HTML page charset encoding to utf8:

meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8

Step 2) set the ‘collation’ attribute for the fields which are to accept hebrew text to: utf8_bin

Step 3) within your php script, right before calling the mysql_query function to insert the data into your DB, use both the utf8_encode function along with addslashes. This will encode the data into utf8 friendly characters.

Step 4) when pulling the text from the DB onto the page, make sure to use the utf8_decode along with stripslashes in order to display the data on the page.


No comments:

Post a Comment