Jump to content
Larry Ullman's Book Forums

Recommended Posts

I am trying to learn multi-language support of php and mysql. I want to insert non-english characters into one of the table, in mysql. My system setup is as follow:


MySQL charset: UTF-8 Unicode (utf8)

Web server



MySQL client version: mysqlnd 5.0.8-dev


php version 5.3.6


I used windows charmap to type and then insert the value in the table. But when I see them in the browser, they are garbage(just english plain text of those other fonts). What extra care should I take? I have indicated specific encoding (UTF-8 charset) in all the scripts as and when require.

My table is same as language table of Ch. 15. I am trying to add another language. All other languages given in the insert query for this table in this book, shows off properly in the browser. But my new language is not showing as it should be. How can I add it?

Does Indian languages need other than UTF-8 charset?

Link to comment
Share on other sites

Do you have the corresponding fonts on your computer? For instance, Bengali can be represented with UTF-8, but I can't see the characters on my computer because I don't have any Bengali font.


Two sites I find useful for non-Latin characters:


Choose a Unicode block in the list, then click on "UTF-8 browser test" to check that you can see these Unicode characters in your browser.



This site is useful for details on all characters.


I hope this helps,

Link to comment
Share on other sites

Thank you Josee.


The sites you gave are useful. I come to know that my language (Gujarati) is UTF-8 unicode characters, and the browsers test runs good on my computer. I have fonts installed on my computer. But I can't see them right from my database. I tried to type a word in charmap, and then paste it in column value. I also tried typing in word processor, and then copy-paste it in column value. But no result. still trying..

Link to comment
Share on other sites

yes, UTF-8 supports Indian characters. I try to type a word in charmap and then copy-paste it in column value. I also try to type a word in wordprocessor and then copy-paste it in column value. But the same problem, I get the english characters instead of the other language. I'm trying, and will let you know of any success. :)

Link to comment
Share on other sites

Well, I got something to dig in. There is a ray of success. I have more than one fonts for the language Gujarati. When I was looking them at charmap utility, I went into advanced view. I listed all fonts using unicode subrange in Group by list box. Unicode subrange box lists my languages like devnagari and gujarati. There I can see character map for a font for devnagari language. I copied some of them in my table, and it shows exactly same as this. But there is no character map for any fonts of gujarati language. (Although they are installed, and I checked them properly in fonts folder.) So, we can say that my computer is ready to show devnagari fonts, but not gujarati. I hope this helps you (you will get what I'm trying to say). And if you get anything from this, then let me know how to insert gujarati language in that unicode character map...

Link to comment
Share on other sites

Hello, Sonal,


I'm not great at fonts, unfortunately, but I think your tests show that your Gujarati fonts are not Unicode. On the following page, from the Unicode official website, maybe you could try to find a free Unicode Gujarati font and download it to your computer so that you can use it in your website.



You can also try this website:



I suppose another solution would be to change the character set for the Gujarati column in your database, but that would probably create more problems than it would solve, particularly if you want to be able to use both English and Gujarati on your web pages.


Good luck! Unicode is supposed to make life simpler on the Internet, but I'm afraid it's still a promise for the future, not for right now!


EDIT: I just found this website that may be useful to you:


Link to comment
Share on other sites

Thank you very much, Josee.

I found an online transliteration IME tool for Indian languages. I type text in it and then copy-paste it into my table. And it worked so far, the output looks nice. I have checked not more than 5 words till now, so keeping an eye on it.

Well, thank you once again as you took time to search for me.

Link to comment
Share on other sites

Hello, Sonal,


Before I had UTF-8 problems using MySQL when storing Chinese characters.

I was trying to store Chinese characters in the data base.

However, after I stored characters in the MySQL database,

MySQL would change the UTF-8 characters to nonsense.

When I retrieved the data it was a mess.


However, I found that the problem was related to MAMP.

After setting up my system to not use MAMP but independently install PHP, MySQL and Apache it

all worked perfect. Possibly, your problem is related to WAMP or MAMP or your IIS set up.

That was my issue before. It seemed like the programmers that put MAMP together set it up in a

UTF-8 unfriendly way.


However, before I independently installed PHP, MySQL and Apache,

I had a another work around in the MAMP system. I would convert the string into binary format, then store it. When

retrieving the characters I would then reconvert the binary back to the orginal string format.

This worked well. I believe it was the base64_encode() and base64_decode() functions that I

used to encode and decode strings before and after inserting into the database. Sorry, I

had this problem about 5 years ago, so I am a little vague on the function I used.

But, I do remember encoding and decoding the string before and after DB storage did

work. A search on php.net's site using the term encode should help you find

the right function to use to encode the string.


Note: Did you test your DB queries using other UTF-8 characters that you know should work?

For example, test Chinese character storage. If Chinese characters do not work then you know it is the database.

If Chinese characters work then you know it is a font issue.


Anyhow, I hope this helps you a little :-)


Link to comment
Share on other sites

Yes Josee, Sure I'll keep updating. I can see gujarati words in my browser window, as explained in multilanguage forum. But they are very few, I will copy-paste the code here, as soon as I complete the page with some meaningful words and content.

Link to comment
Share on other sites

Hi Josee,

A little update. Now I am able to insert data through the PHP form. I have done nothing special other than instructions given in Larry's book, as in message board example. I tried typing gujarati words in the form using online IME tool and also with Windows change keyboard facility. I set it for gujarati language, and it lets me add new record in mysql through php form. So, it seems you helped me to get right (unicode) characters, so now they are showing up. My script is similar to the example of the book. Do you want me to paste it here?

Link to comment
Share on other sites


I am trying to develop a multilanguage website. Till now, I can insert and retrieve gujarati language properly. Well, there is no big content, but I'm using the instructions given in this book only. It seems that gujarati characters are unicode, so they are working fine. I would like to share the coding. Do I copy-paste different files?

Link to comment
Share on other sites

Hello, Sonal,


I'm glad it's working for you. You've certainly helped yourself more than I have been able to help you!


As for the script, I don't think you need to paste it here if it's similar to the one in Larry's book; I suppose anyone reading this post will have the book, or can download the script from the website.


Good luck with your multilingual website!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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