Les Snippets

Connexion

Ainsi vers UTF8 et vice versa

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 25/03/2006 23:01:52 et initié par EBArtSoft [Liste]
Date de mise à jour : 20/12/2007 11:06:04
Vue : 4968
Catégorie(s) : API, Cryptage, Fichier / Disque, Trucs & Astuces, Chaîne de caractères
Langages dispo pour ce code :
- VB6



Langage : VB6
Date ajout : 25/03/2006
Posté par EBArtSoft [Liste]
DateMAJ : 20/12/2007

Private Const CP_UTF8 = 65001
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As String, 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 String, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long

Public Function AToUTF8(ByVal wText As String) As String
    Dim vNeeded As Long
    Dim vSize   As Long
    vSize = Len(wText)
    vNeeded = WideCharToMultiByte(CP_UTF8, 0, StrPtr(wText), vSize, "", 0, 0, 0)
    AToUTF8 = String(vNeeded, 0)
    WideCharToMultiByte CP_UTF8, 0, StrPtr(wText), vSize, AToUTF8, vNeeded, 0, 0
End Function

Public Function UTF8ToA(ByVal wText As String) As String
    Dim vNeeded As Long
    Dim vSize   As Long
    vSize = Len(wText)
    vNeeded = MultiByteToWideChar(CP_UTF8, 0, wText, vSize, 0, 0)
    UTF8ToA = String(vNeeded, 0)
    MultiByteToWideChar CP_UTF8, 0, wText, vSize, StrPtr(UTF8ToA), vNeeded
End Function

' ==== Utilisation :
'Private Sub Command3_Click()
'    Text1 = "EBArtSoft%20-%20éàéçڳگڦà¸"
'    Text2 = UTF8ToA(Replace(Text1, "%20", " "))
'    Text3 = AToUTF8(Replace(Text2, " ", "%20"))
'End Sub



Snippets en rapport avec : Transformation, Ainsi, Utf8



Codes sources en rapport avec : Transformation, Ainsi, Utf8

{ASP / ASP.NET} CONVERSION CARACTÈRES UTF-8 VERS FRANÇAIS
En ASP (pas en ASP .net), je n'ai pas trouvé de fonction de transformation des caractères UTF-8 en I...

{C# / C#.NET} SUPPRIMER LES TAG BOM DANS FICHIER UTF-8
Ce programme vous permettra du supprimer les tags au début des fichiers UTF-8 BOM. J’ai rajouté la ...

{Visual Basic, VB6, VB.NET, VB 2005} ENCODER UNE URL EN UTF8 DEPUIS WORD
Si on veut créer des URL correctes dans Word, il est nécessaire d'encoder convenablement tout ce qui...

{PHP} [PHP5] EXCEPTIONERROR PACKAGE : TRANSFORMER TOUTES LES ERREURS PHP EN EXCEPTIONS INTERCEPTABLES
Ce package permet de transformer toutes les erreurs PHP en exceptions interceptables. En clair, sur...

{Delphi} MAILS AVEC INDY10, RÉSOLUTION DU PROBLÈME LORSQUE CHARSET = UTF-8
Indy10 est après moultes tests, (pour moi) le meilleur package de compos orienté communications rése...

{JAVA / J2EE} DKSWARPEDITOR : TRANSFORMEZ UNE IMAGE TRÈS SIMPLEMENT
Voici de nouveau une source qui fera parti d'une source beaucoup plus ambitieuse que je mettrais une...

{Delphi} MORPHING ENTRE DEUX IMAGES
Petit utilitaire de Morphing, code assez crade, mais efficace :)))))...

{PHP} CONVERSION UNIVERSELLE DE CARACTÈRES
Bonjour, c'est pour faire face à un dilemne que j'ai pondu cette source. En effet, certains utilisen...

{PHP} PHP5 CLASSE GÉNÉRIQUE GESTION ROUTINES MYSQL
......

{Visual Basic, VB6, VB.NET, VB 2005} TRAITEMENT DES COULEURS (ÉCLAICISSEMENT, CONTRASTE, ETC...) D'UNE IMAGE
Simplement de quoi apprendre à effectuer ces traitements : - renforcements de tonalités - combinai...