I do not have a problem when retrieving arabic text data from mysql database. But when the input Arabic text into my database is having problems. Arabic text changed to "????", so it can not be read. after looking for a solution, I found a way to solve it.
First, the Arabic text should be encoded first by using the code:
StrToEncode String = "بسم الله";
String encoded = URLEncoder.encode (strToEncode, "UTF-8");
now, that has been encoded strToEncode changed to:
% D8% A8% D8% B3% D9% 85 +% D8% A7% D9% 84% D9% 84% D9% 87
encode the string that is inserted into the mysql. then to read the Arabic text data from mysql database needs to be decoded using the code:
String correctDecoded = URLDecoder.decode (encoded, "UTF-8");
and the results of correctDecode:
بسم الله
No comments:
Post a Comment