1

I am receiving unicode charactors in FB Graph requests for the user's name.. How can i convert it to english in iOS app ? Also is anything like this available in PHP as well ?

mjs
  • 657
  • 7
  • 14
  • Why would you try to convert unicode names to English ? – Mihai Iorga Sep 13 '12 at 07:06
  • My iOS app is fetching FB name using the FB ID of the user.. FB is returning the name in unicode .. i have to display this name in game – mjs Sep 13 '12 at 07:08
  • Then display his name in Unicode, I would hate your app if my name had unicode characters and your app displayed my name in some foreign language that I am sure 100% will not be accurate. – Mihai Iorga Sep 13 '12 at 07:10
  • \u9648\u73ab\u7af9 displaying this as name ? that can be done but i want to explore other options ..i know the locale is "locale": "zh_CN" so how to display this in chinese characters or maybe some english equivalent name – mjs Sep 13 '12 at 07:20

1 Answers1

2

The best answer for this is to display his name in his language.

The best conversion It's coming into my mind is using json_decode():

$name = '\u9648\u73ab\u7af9';
echo json_decode('"'.$name.'"');
// ouputs: 陈玫竹

I suggested json_decode() because it supports the \uxxxx syntax directly and other unicode or utf-8 characters.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
  • thanks dis works great for PHP .. im still exploring if smthing lyk dis in available in iOS as well .. – mjs Sep 13 '12 at 07:33
  • uhm, maibe [this](http://stackoverflow.com/questions/3165290/how-to-parsing-json-object-in-iphone-sdk-xcode-using-json-framework) will help you getting same result in iOS. – Mihai Iorga Sep 13 '12 at 07:35