UTF-8 commenvertir un fichier ASCI en UTF-8

alfajac Messages postés 17 Date d'inscription mercredi 12 mars 2003 Statut Membre Dernière intervention 20 septembre 2005 - 16 mai 2004 à 19:39
hugoclavet Messages postés 10 Date d'inscription vendredi 5 novembre 2004 Statut Membre Dernière intervention 1 mars 2008 - 1 mars 2008 à 23:54
lut,

je vdeveloppe en VBA sur ACCESS

je dois compiler un fichier XML avec des instructions pour creer un fichier de commande (references article ..).

ce fichier doit contenir du code UFT-8.

comment faire SVP ?

qq'un a un code a me passer ?

Merci d'avance a tous

8-) Le Negociateur
A voir également:

1 réponse

hugoclavet Messages postés 10 Date d'inscription vendredi 5 novembre 2004 Statut Membre Dernière intervention 1 mars 2008
1 mars 2008 à 23:54
Je sais plus ou j'ai pris ça. dsl

Option Compare Database
Option Explicit


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


Private Const CP_ACP = 0
Private Const CP_UTF8 = 65001


Public Function UTF8_Encode(ByVal Text As String) As String


Dim sBuffer As String
Dim lLength As Long


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)


End Function


Public Function UTF8_Decode(ByVal Text As String) As String


Dim lLength As Long
Dim sBuffer As String


Text = StrConv(Text, vbFromUnicode)
lLength = MultiByteToWideChar(CP_UTF8, 0, StrPtr(Text), -1, 0, 0)
sBuffer = Space$(lLength)
lLength = MultiByteToWideChar(CP_UTF8, 0, StrPtr(Text), -1, StrPtr(sBuffer), Len(sBuffer))
UTF8_Decode = Left$(sBuffer, lLength - 1)


End Function

Hugo
0
Rejoignez-nous