Error in Arabic script in MySQL
Question
I inserted data in a MySQL database which includes Arabic script. While the output displays Arabic correctly, the data in MySQL looks like garbage. Something like this:
'صَومُ ثَلاثَةِ أيّامٍ مِن كُلِّ شَهرٍ ـ أربَعاءُ بَينَ خَ
Should I be worried about this? If yes, how do I make it appear in proper Arabic script in MySQL?
Solution
Those are HTML entities.
If this text
صَومُ ثَلاثَةِ أيّامٍ مِن كُلِّ شَهرٍ ـ أربَعاءُ بَينَ خَ
is what is supposed to be in your database, everything's most likely fine: Your arabic input gets converted into those entities at some point along the way.
To view the actual arabic characters like above, insert them into a text file, name it something.htm
and open it in your browser.
You could also convert it into "proper" native characters in a UTF-8 encoded mySQL table, but for you to get any pointers how to do that you would have to tell us what languages/platforms you are working with.
OTHER TIPS
As @Pekka says, those are HTML entities.
However, I can't help but think using UTF-8 (for both the database connection and HTML encoding) might save you some pain in the long run. Likewise, if at all possible (i.e.: if this is a "new" system rather than an existing codebase) I'd recommend storing the data raw in the database (using mysql_real_escape_string to prevent SQL injection, etc.) and HTML encoding at the point of output.
In general, this will make it easier to search the data, etc.