En Visual Basic, lorsqu'on reçoit des courriels et qu'on souhaite les lires, il y a très peut de support permettant l'interprétation. Ainsi, il n'existe même pas de fonction permettant la conversion des caractères ISO 8859 à ANSI, lequel est pourtant très répandu sur le Web.
Voici maintenant le code source Visual Basic permet de convertir un caractère ISO 8859 en format ANSI :
- Function ISO8859ToAnsi(sText)
- sText = Replace(sText,"=" & vbCRLF,"")
- sText = Replace(sText,"=" & Chr(13),vbCRLF)
- sText = Replace(sText,"=" & Chr(10),vbCRLF)
- sText = Replace(sText,"=09"," ")
- sText = Replace(sText,"=20"," ")
- sText = Replace(sText,"=21","!")
- sText = Replace(sText,"=28","(")
- sText = Replace(sText,"=29",")")
- sText = Replace(sText,"=2E",".")
- sText = Replace(sText,"=3A",":")
- sText = Replace(sText,"=3D","=")
- sText = Replace(sText,"=92","'")
- sText = Replace(sText,"=A0"," ")
- sText = Replace(sText,"=AB","«")
- sText = Replace(sText,"=AE","®")
- sText = Replace(sText,"=BB","»")
- sText = Replace(sText,"=C0","À")
- sText = Replace(sText,"=C7","Ç")
- sText = Replace(sText,"=C9","É")
- sText = Replace(sText,"=CA","Ê")
- sText = Replace(sText,"=CB","Ë")
- sText = Replace(sText,"=CE","Î")
- sText = Replace(sText,"=D4","Ô")
- sText = Replace(sText,"=D6","Ö")
- sText = Replace(sText,"=DB","Û")
- sText = Replace(sText,"=E0","à")
- sText = Replace(sText,"=E2","â")
- sText = Replace(sText,"=E7","ç")
- sText = Replace(sText,"=E8","è")
- sText = Replace(sText,"=E9","é")
- sText = Replace(sText,"=EA","ê")
- sText = Replace(sText,"=EB","ë")
- sText = Replace(sText,"=EE","î")
- sText = Replace(sText,"=F4","ô")
- sText = Replace(sText,"=F6","ö")
- sText = Replace(sText,"=FB","û")
- ISO8859ToAnsi = sText
- End Function
-
- Sub Main()
- MsgBox ISO8859ToAnsi("Message ayant =E9t=E9 envoy=E9 par courriel")
- End Sub
on obtiendra le résultat suivant :
Message ayant été envoyé par courriel
Dernière mise à jour : Lundi, le 19 novembre 2012