Search code examples
c#objective-cunicodeencode

Cyrillic NSString to Unicode in objective-c


I want to send Cyrillic string as parameter over webservice from iPhone to .net framework server. How should I encode it correctly? I would like the result to be something like:

"myParam=\U0438\U0422"

If it's doable, would it matter if it is Cyrillic or just Latin letters?

And how should I decode it on the server, where I am using C#?


Solution

  • I would like the result to be something like "myParam=\U0438\U0422"

    Really? That's not the standard for URL parameter encoding, which would be:

    myParam=%d0%b8%d0%a2
    

    assuming the UTF-8 encoding, which will be the default for an ASP.NET app. You don't need to manually decode anything then, the Request.QueryString/Form collections will give you native Unicode strings.

    URL-encoding would normally be done using stringByAddingPercentEscapesUsingEncoding, except that it's a bit broken. See this question for background.