Let me start saying that I did some homework, but I did not find any answer to my question.
I'm trying to use the translate.google.com/translate_a url to translate single word from swedish to english. I'm doing this in objective-c.
here is an example:
word = @"hus"; // result should be "house"
urlPath = [NSString stringWithFormat:@"/translate_a/t?client=t&text=%@&langpair=sv|en", word];
url = [[NSURL alloc] initWithScheme:@"http" host:@"translate.google.com" path:urlPath];
NSLog(@"%@\n\n", url);
request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"GET"];
myData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
result = [[NSString alloc] initWithData:myData encoding: NSASCIIStringEncoding];
NSLog(@"%@\n\n", result);
self.viewController.textViewGood.text = result;
the NSLog gives me this url:
http://translate.google.com/translate_a/t?client=t&text=hus&langpair=sv%7Cen
the NSLog also shows the correct result:
2013-03-01 00:07:14.681 testGoogTrans[941:11303] [[["house","hus","",""]]
etc..
If I now call the url shown before in a browser, I get a file with the same result inside.
So this is working fine on both the app and the browser.
now, by changing only the word, that has a special char:
word = @"tåg"; // result should be "train"
and the rest remaining the same, I get a strange different result:
the printed url in the console:
http://translate.google.com/translate_a/t?client=t&text=t%C3%A5g&langpair=sv%7Cen which seems to be correctly escaped.
if I call this url in a browser, I get a file with the following content:
[[["trains","tåg","",""]],[["nom",["TRAIN","MARCH","ROPE","MARCHING","EXPEDITION","PROCESSION"]
etc... which is what I expect.
instead, in the app, the result shown in the console is:
[[["t\u00C3 \u00A5 g","t\u00C3\u00A5g","",""]],,"sv",,[["t\u00C3",[5],1,0,998,0,1,0]
etc...
i believe the url is correctly formatted, and I don't know why i get a different answer from within the app.
anyone knows something about this or can put me on the direction to solve that?
thanks in advance