Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Translate Api and Special Characters

I've recently started using the google translate API inside a c# project. I am trying to translate some text from english to french. I am having issues with some special characters though.

For example the word Company comes thru as Société instead of Société as it should. Is there some way in code I can convert these to the correct special characters? ie (é to é)

Thanks

If you need anymore info let me know.

like image 448
Caleb Sandfort Avatar asked Dec 02 '25 04:12

Caleb Sandfort


1 Answers

I ran into this same exact issue. If you're using the WebClient class to download the json response from google, try setting the Encoding property to UTF8.

using(var webClient = new WebClient { Encoding = Encoding.UTF8 })
{
    string json = webClient.DownloadString(someUri);
    ...
}
like image 53
tdaines Avatar answered Dec 03 '25 17:12

tdaines