RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About
  •  

    Solution to retrieving devanagari / hindi / marathi from MySQL database

    May 14th, 2009

    Web developers working with Indian devanagari language may face some issues while pulling out strings from the MySQL database. If not done correctly, one will get a series of question marks instead of the devanagari.

    Solution:

    Set the ‘collation’ of the database, table and column to ‘utf8_unicode_ci‘. Now, whenever you want to retrieve the unicode string, simply run the below given query before running the actual query to retrieve the unicode string.

    mysql_query("SET NAMES 'utf8'");//run this query first
    $resource=mysql_query('SELECT book_title FROM hindi_marathi_books');

    Thats it! Now use PHP to parse the strings as you like!