Thanos_the_yopper
Messages postés309Date d'inscriptionvendredi 9 janvier 2004StatutMembreDernière intervention 5 mars 2009
-
13 mai 2004 à 16:16
Thanos_the_yopper
Messages postés309Date d'inscriptionvendredi 9 janvier 2004StatutMembreDernière intervention 5 mars 2009
-
13 mai 2004 à 16:53
voila, j'utilise, en VB6 cette fonction pour convertire du texte en UTF-8 :
Private Const CP_UTF8 = 65001
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long
Public Function UTF8_Encode(ByVal Text As String) As String
Dim sBuffer As String
Dim lLength As Long
If Text <> "" Then
lLength = WideCharToMultiByte(CP_UTF8, 0, StrPtr(Text), -1, 0, 0, 0, 0)
sBuffer = Space$(lLength)
lLength = WideCharToMultiByte(CP_UTF8, 0, StrPtr(Text), -1, StrPtr(sBuffer), Len(sBuffer), 0, 0)
sBuffer = StrConv(sBuffer, vbUnicode)
UTF8_Encode = Left$(sBuffer, lLength - 1)
Else
UTF8_Encode = ""
End If
ça marche parfaitement avec Win98, NT et 2000 mais pas sous 95 :/ j'ai ce message d'erreur :
Erreur d'execution '5':
Argument ou appel de procédure incorrect
l'erreur se produit à la ligne :
UTF8_Encode = Left$(sBuffer, lLength - 1)
Apprement, c'est parce qu'il y a plein de caractere spécial dans la variable sBuffer
quelqu'un à une idée d'où ça peut venir ? désolé de faire le bourin et de le poster sur plusieur forum mais si je trouve pas d'ici ce soir, je serais grave dans la mouise -_-
Thanos_the_yopper
Messages postés309Date d'inscriptionvendredi 9 janvier 2004StatutMembreDernière intervention 5 mars 2009 13 mai 2004 à 16:53
ok, je viend de comprendre l'erreur ... c'est parce que lLength est égal à 0.
Donc le probleme vient de MultiByteToWideChar, qui apparement ne marcherait pas sous win95 ? ILength est à 0 et sBuffer est vide après execution de MultiByteToWideChar ... sérieux, si quelqu'un est capable de m'aider, je lui envoie un savane par la poste !!!!