1

I have developed an API in node js for mobile applications developed in android and iOS. One of the user of the app input the name as "ساجار" (arabic font) and it got stored in database as it is. The name is displayed as it is in the iOS app but the android app displays some junk. Can someone tell me if I need to make some changes in the API or something on the android app end and what is to be done?

XCEPTION
  • 1,671
  • 1
  • 18
  • 38

2 Answers2

1

Use Escape Sequence characters. A tool like this: http://www.freeformatter.com/javascript-escape.html can help you. It escapes the characters, example:

ساجار -> \u0633\u0627\u062C\u0627\u0631

Before submitting to database, you can submit it as Unicode escaped characters itself, so that no work would be needed in Android side.

Refer this.

Faced same problem, Used php to escape the characters and submit to database/JSON file. Let me know if you've any doubts.

Community
  • 1
  • 1
Anirudh Murali
  • 612
  • 10
  • 25
  • I have implemented this currently but then I have to decode the unicode to text when I have to use it right? which is what I am doing currently – XCEPTION Jan 25 '16 at 06:53
  • No, you need not have to decode it. exceptnothing.com/doctors.json Look at this, this is the JSON file I'm using for my app. Those JSON details gets parsed into a ListView. I do not decode it, it shows in the correct language. If still the language isn't shown, try using characters for a French word with accents, if that works fine, then Arabic font might be missing. – Anirudh Murali Jan 25 '16 at 06:57
  • Depending upon the language, I never included a Tamil font, yet it as shown. I am not sure whether phones include Arabic font. Or if not, set custom font for the text view where the Arabic text will appear: www.androidhive.info/2012/02/android-using-external-fonts/ – Anirudh Murali Jan 25 '16 at 07:09
  • Is the title value for example "\u0BAE\u0BB0\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0BB5\u0BB0\u0BBF\u0BA9\u0BCD \u0BAA\u0BC6\u0BAF\u0BB0\u0BCD #2" stored in the same unicode format in database? – XCEPTION Jan 25 '16 at 07:30
  • I don't use Database mate. I use http://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/, it parses the JSON to ListView. – Anirudh Murali Jan 25 '16 at 07:33
0

if you're using JSON, then you may need to change your request content-type header from

"application/json"

to

"application/json; charset=utf-8"

Abdullah Shoaib
  • 2,065
  • 2
  • 18
  • 26