Note that there are some explanatory texts on larger screens.

plurals
  1. POWrong encoding when getting response from Google's translate API?
    text
    copied!<p>I am using google's translate API to translate some text in the iPhone SDK. The URL I use is <a href="http://ajax.googleapis.com/ajax/services/language/translate?v=1.0" rel="nofollow noreferrer">http://ajax.googleapis.com/ajax/services/language/translate?v=1.0</a></p> <p>Everything works, except in some languages, Polish for example, the returned string sometimes have weird things like \u0026 as part of the string. It would show as "hello how ar\u0026e you". Why is this? The way I fetch for the result is as follows:</p> <pre><code> NSData *returnData = [NSURLConnection sendSynchronousRequest: req returningResponse: response error: error]; NSString *new = [[NSString alloc] initWithData:responseData encoding: NSUTF8StringEncoding]; </code></pre> <p>Is the encoding incorrect? Is that why the new string appears to be incorrect? I've tried the same text int he google translate webpage and it gets translated correctly. </p> <hr> <p><strong>UPDATE</strong></p> <p>If you simply go to this <a href="http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q=%EF%BC%93%EF%BC%A7%E3%81%AA%E3%81%AE%E3%81%A7%E3%83%A1%E3%83%A2%E3%83%AA%E4%B8%8D%E8%B6%B3%E3%81%AB%E3%82%88%E3%82%8B%E3%83%A2%E3%83%83%E3%82%B5%E3%82%8A%E5%8B%95%E4%BD%9C%E3%81%8C%E6%B0%97%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%0A%E7%84%A1%E6%96%99%E3%81%AE%E3%82%BD%E3%83%95%E3%83%88%E3%81%A7%E3%83%A1%E3%83%A2%E3%83%AA%E8%A7%A3%E6%94%BE%E3%81%8C%E5%87%BA%E6%9D%A5%E3%81%A6%E5%8A%A9%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%0A%E8%87%AA%E5%88%86%E3%81%A8%E3%81%97%E3%81%A6%E3%81%AF%E3%80%81%E3%82%A2%E3%82%A4%E3%82%B3%E3%83%B3%E3%82%92%E3%83%AF%E3%83%B3%E3%82%AF%E3%83%AA%E3%83%83%E3%82%AF%E3%81%97%E3%81%9F%E3%82%89%E3%80%8C%E8%A7%A3%E6%94%BE%E3%80%8D%E3%80%8C%E3%82%A2%E3%83%97%E3%83%AA%E7%B5%82%E4%BA%86%E3%80%8D%E3%81%A8%E3%81%AA%E3%82%8B%E3%81%A8%E5%AC%89%E3%81%97%E3%81%84&amp;langpair=%7Cen" rel="nofollow noreferrer">URL</a>, you will see the special characters. How do I correctly represent those characters in my app? Using the two lines of code above will not encode it correctly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload