ddove53
Messages postés623Date d'inscriptionmardi 20 mars 2007StatutMembreDernière intervention15 juin 2010
-
1 sept. 2009 à 10:40
ddove53
Messages postés623Date d'inscriptionmardi 20 mars 2007StatutMembreDernière intervention15 juin 2010
-
2 sept. 2009 à 10:30
Bonjour, je du texte traduit à partir de google Translator. Mon problème c'est que certains caractères de la traduction récupérée ne sont pas reconnus malgrè l'utilisation de UTF-8. Voici un bout de code:
Public Sub New()
MyBase.New("Google Translator", "http://translate.google.com/translate_t", New String(,) {{"ar", "en"}, _
{"zh", "en"}, {"zh-CN", "zh-TW"})
End Sub
Public Overrides Function GetPostData(ByVal inputLanguage As String, ByVal outputLanguage As String, ByVal [text] As String) As String
Return "text=" + Encode(text) + "&sl=" + inputLanguage + "&tl=" + outputLanguage
End Function
Protected Overridable Function GetTranslation(ByVal inputLanguage As String, ByVal outputLanguage As String, ByVal innerText As String) As String
Return innerText
End Function
Public Overrides Function Translate(ByVal inputLanguage As String, ByVal outputLanguage As String, ByVal [text] As String) As String
Dim toReturn As String = ""
Dim innerText As String = Me.GetInnerText(Me.GetPostData(inputLanguage, outputLanguage, [text]))
toReturn = Me.GetTranslation(inputLanguage, outputLanguage, innerText)
......
Dim utfS As Encoding = System.Text.Encoding.ASCII
Dim utfD As Encoding = System.Text.Encoding.UTF8
Return (utfD.GetString(Encoding.Convert(utfS, utfD, utfS.GetBytes(toReturn))))
End Function
Le problème se situe au niveau de la traduction que retourne la fonction Translate (toReturn).
Pouvez-vous m'aider?
Merci.