First of all, is not a solution for me to pay for a GoogleTranslate API.
I'm trying to translate with a Get method a simple phrase that contains a especial character "&".
"Me & You"
This is the method I wrote:
Public Function Google_Translate(ByVal Input As String, _
ByVal From_Language As Languages, _
ByVal To_Language As Languages) As String
Dim webClient As New System.Net.WebClient
Dim str = webClient.DownloadString( _
"http://translate.google.com/translate_a/t?client=t&text=" & Input & _
"&sl=" & Formatted_From_Language & _
"&tl=" & Formatted_To_Language & "")
' Debug: MsgBox(str)
Return (str.Substring(4, str.Length - 4).Split(ControlChars.Quote).First)
End Function
This is a usage example:
Google_Translate("Me and you", Languages.en, Languages.en)
The result is the same string 'cause I've translated from english to english:
"Me and you"
The problem is when I try to use any especial HTML character, for example the "&":
Google_Translate("Me & you", Languages.en, Languages.en)
Result:
"Me"
This is the string without the split:
[[["Me","Me","",""]],,"en",,,,,,,0]
This is all I've tried:
Unicode identifiers:
Google_Translate("Me \u0026 you")
HTML Entities:
Google_Translate("Me & you")
HTML Escaped entities:
Google_Translate("Me &H38; you")
...And HTML percents:
Google_Translate("Me %26 you")
...Calling the method using the percents I get a string with an Unicode identifier:
[[["Me \u0026 you","Me \u0026 you","",""]],,"en",,,,,,[["en"]],0]
That maybe will mean the only thing that I need to do is to get the string from Google and translate the unicode identifier and that's all? ...NOT! 'cause if I call Google using other special character, I don't get any unicode identifier:
Google_Translate("Hello·"" World¿?", GoogleTranslate_Languages.en, GoogleTranslate_Languages.en)
Result:
"Hello·\" World¿?"
Result without the split:
[[["Hello·\" World¿?","Hello·\" World¿?","",""]],,"en",,,,,,[["en"]],0]
What I'm missing?
How I can send/get the data in the correct way using especial characters as &%$"¿? ?