Reputation:
While creating database for my website I used below syntax.
CREATE DATABASE myDatabase DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Now while my client is entering arabic characters, he see some weird output. I am using JSF 2.0 for web pages.
What changes do I need to make so that I can enter Arabic or any characters in my site and it get stored in DB.
While I am printing the data, I am seeing output as شسÙ?بشسÙ? بشسÙ?ب شسÙ?ب
I am using web application using JSF 2.0
Upvotes: 1
Views: 1643
Reputation: 71
I think you must use cp1256_general_ci
instead of utf8_general_ci
,
and don't forget to set the collation of the database and all fields that may contain Arabic words to utf8_general_ci
.
Upvotes: 0
Reputation: 9084
Use N'' when you insert data values, This denotes that the subsequent string is in Unicode (the N actually stands for National language character set)
INSERT INTO table VALUES(N'ArabicField');
Upvotes: 1
Reputation: 122032
You should set UTF8 charset for the connection before the inserting/reading data -
SET NAMES utf8;
INSERT INTO table VALUES(...);
SELECT * FROM table;
Upvotes: 1