1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

sbjson - multi language

Discussion in 'iPhone/iPad Programming' started by mpramodjain, Apr 28, 2011.

  1. macrumors regular


    Had anyone had used multi-languages (other than english), mean unicode characters contained JSON with SBJSONParser, and had any luck with this parsing.

    I tried but not getting the exact parsed content.

    To say

    I passed JSON Object containing Arabic text,

    But it returns /u.. some other content.

    Please let us know if anyone had got resolved this issue before.

  2. macrumors regular

  3. PhoneyDeveloper, Jun 8, 2011
    Last edited: Jun 8, 2011

    macrumors 68030


    I believe that JSON uses UTF-8 text so there should be no problems at all with the parser. Are you sure that the JSON is valid UTF-8? I would inspect it before it's parsed.

    One other thing, there are other available JSON parsing libraries and you might compare their output. I'm using JSONKit, which has been reported to be the fastest Obj-C JSON parser.
  4. macrumors regular

    Thanks for your reply PhoneyDev.

    I am using SBJSON Parser, as it was much easier I found, and doesn't have much impact on my application.

    Now I had tried Spanish language content parsing, it works fine. But where as I tried to parse the Arabic/Urdu content, I got the different parsed content as "\u\u".. like this,

    Any idea ? why this happens.
  5. PhoneyDeveloper, Jun 10, 2011
    Last edited: Jun 10, 2011

    macrumors 68030


    I don't have any idea why that happens. Have you printed out the JSON before it's parsed? Or save it to a file and open it in a UTF-8 aware text editor.

    Are the escapes present in the JSON or are they added by the parser?

    Hmmm, I just happened to be looking at some JSON from FaceBook and I see that there are escaped characters in it. I see them for curly quotes and a few other non-ascii special characters. I see something like "the world\u2019s best..." where I guess the escaped character is a curly quote. I haven't tried it but I assume that those characters are correctly parsed by all the usual parsers.

    If you're really getting a result string that contains "\u\u" that sounds like a bug. Either the JSON is not valid or the parser has a bug.

    One other question: where do you see the "\u\u"? In a textview or label or some other view on the device or in the debugger or in the debugger console? Is it possible that the phone doesn't have a font with the correct characters?

Share This Page