Les Snippets

Connexion

Modifie les caractères spéciaux

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 17/05/2006 10:24:01 et initié par danielamaury [Liste]
Date de mise à jour : 27/08/2007 12:35:47
Vue : 13706
Catégorie(s) : Chaîne de caractères, WinForm, WebForm
Langages dispo pour ce code :
- ASP.NET 2.x, VB 2005
- VB6
- VB6, VBA
- ASP.NET 1.x, ASP.NET 2.x, C# 1.x, C# 2.x
- Delphi 5



Langage : VB 2005 , ASP.NET 2.x
Date ajout : 17/05/2006
Posté par danielamaury [Liste]

 Public Shared Function Modifcarracters(ByVal UnMot As String) As String
        UnMot = Replace(UnMot, Chr(138), "S")
        UnMot = Replace(UnMot, Chr(142), "Z")
        UnMot = Replace(UnMot, Chr(158), "z")
        UnMot = Replace(UnMot, Chr(159), "Y")
        UnMot = Replace(UnMot, Chr(192), "A")
        UnMot = Replace(UnMot, Chr(193), "A")
        UnMot = Replace(UnMot, Chr(194), "A")
        UnMot = Replace(UnMot, Chr(195), "A")
        UnMot = Replace(UnMot, Chr(196), "A")
        UnMot = Replace(UnMot, Chr(197), "A")
        UnMot = Replace(UnMot, Chr(200), "E")
        UnMot = Replace(UnMot, Chr(201), "E")
        UnMot = Replace(UnMot, Chr(202), "E")
        UnMot = Replace(UnMot, Chr(203), "E")
        UnMot = Replace(UnMot, Chr(204), "I")
        UnMot = Replace(UnMot, Chr(205), "I")
        UnMot = Replace(UnMot, Chr(206), "I")
        UnMot = Replace(UnMot, Chr(207), "I")
        UnMot = Replace(UnMot, Chr(208), "D")
        UnMot = Replace(UnMot, Chr(209), "N")
        UnMot = Replace(UnMot, Chr(210), "O")
        UnMot = Replace(UnMot, Chr(211), "O")
        UnMot = Replace(UnMot, Chr(212), "O")
        UnMot = Replace(UnMot, Chr(213), "O")
        UnMot = Replace(UnMot, Chr(214), "O")
        UnMot = Replace(UnMot, Chr(217), "U")
        UnMot = Replace(UnMot, Chr(218), "U")
        UnMot = Replace(UnMot, Chr(219), "U")
        UnMot = Replace(UnMot, Chr(220), "U")
        UnMot = Replace(UnMot, Chr(221), "Z")
        UnMot = Replace(UnMot, Chr(224), "a")
        UnMot = Replace(UnMot, Chr(225), "a")
        UnMot = Replace(UnMot, Chr(226), "a")
        UnMot = Replace(UnMot, Chr(227), "a")
        UnMot = Replace(UnMot, Chr(228), "a")
        UnMot = Replace(UnMot, Chr(229), "a")
        UnMot = Replace(UnMot, Chr(231), "c")
        UnMot = Replace(UnMot, Chr(232), "e")
        UnMot = Replace(UnMot, Chr(233), "e")
        UnMot = Replace(UnMot, Chr(234), "e")
        UnMot = Replace(UnMot, Chr(235), "e")
        UnMot = Replace(UnMot, Chr(236), "i")
        UnMot = Replace(UnMot, Chr(237), "i")
        UnMot = Replace(UnMot, Chr(238), "i")
        UnMot = Replace(UnMot, Chr(239), "i")
        UnMot = Replace(UnMot, Chr(241), "n")
        UnMot = Replace(UnMot, Chr(242), "o")
        UnMot = Replace(UnMot, Chr(243), "o")
        UnMot = Replace(UnMot, Chr(244), "o")
        UnMot = Replace(UnMot, Chr(245), "o")
        UnMot = Replace(UnMot, Chr(246), "o")
        UnMot = Replace(UnMot, Chr(249), "u")
        UnMot = Replace(UnMot, Chr(250), "u")
        UnMot = Replace(UnMot, Chr(251), "u")
        UnMot = Replace(UnMot, Chr(252), "u")
        UnMot = Replace(UnMot, Chr(253), "y")
        UnMot = Replace(UnMot, Chr(255), "y")
        Return CStr(UnMot)
End Function

Remarque :
Converti les caractères spéciaux en caractères simple.
Langage : VB6
Date ajout : 01/06/2006
Posté par PCPT [Liste]

Private Function ModifCaracters(ByVal UnMot As StringAs String 
    ModifCaracters = UnMot 
    Dim i As Integer 
    For i = 1 To Len(UnMot) 
        Select Case Asc(Mid$(UnMot, i, 1)) 
                Case 138:                           Mid$(ModifCaracters, i, 1) = "S" 
                Case 142, 221:                      Mid$(ModifCaracters, i, 1) = "Z" 
                Case 158:                           Mid$(ModifCaracters, i, 1) = "z" 
                Case 159:                           Mid$(ModifCaracters, i, 1) = "Y" 
                Case 192, 193, 194, 195, 196, 197:  Mid$(ModifCaracters, i, 1) = "A" 
                Case 200, 201, 202, 203:            Mid$(ModifCaracters, i, 1) = "E" 
                Case 204, 205, 206, 207:            Mid$(ModifCaracters, i, 1) = "I" 
                Case 208:                           Mid$(ModifCaracters, i, 1) = "D" 
                Case 209:                           Mid$(ModifCaracters, i, 1) = "N" 
                Case 210, 211, 212, 213, 214:       Mid$(ModifCaracters, i, 1) = "O" 
                Case 217, 218, 219, 220:            Mid$(ModifCaracters, i, 1) = "U" 
                Case 224, 225, 226, 227, 228, 229:  Mid$(ModifCaracters, i, 1) = "a" 
                Case 231:                           Mid$(ModifCaracters, i, 1) = "c" 
                Case 232, 233, 234, 235:            Mid$(ModifCaracters, i, 1) = "e" 
                Case 236, 237, 238, 239:            Mid$(ModifCaracters, i, 1) = "i" 
                Case 241:                           Mid$(ModifCaracters, i, 1) = "n" 
                Case 242, 243, 244, 245, 246:       Mid$(ModifCaracters, i, 1) = "o" 
                Case 249, 250, 251, 252:            Mid$(ModifCaracters, i, 1) = "u" 
                Case 253, 255:                      Mid$(ModifCaracters, i, 1) = "y" 
        End Select 
    Next i 
End Function

Langage : VB6 , VBA
Date ajout : 19/02/2007
Posté par pifou25 [Liste]
DateMAJ : 29/03/2007
  • Public Function StripSpecialChars(ByVal iString As String, Optional _
  • CompareMethod As VbCompareMethod = vbTextCompare, Optional Lookup As String _
  • = "àâäéèêëïùç", Optional ReplaceBy As String = "aaaeeeeiuc") As String
  • Dim i As Long
  • ' dans le doute on remplace pas on supprime le caractère
  • If Len(ReplaceBy) < Len(Lookup) Then ReplaceBy = ""
  • For i = 1 To Len(Lookup)
  • ' on remplace tous les caractères de Lookup 1 par 1 dans iString
  • iString = Replace(iString, Mid(Lookup, i, 1), (IIf(ReplaceBy = "", "", _
  • Mid(ReplaceBy, i, 1))), , , CompareMethod)
  • Next i
  • StripSpecialChars = iString
  • End Function
  • Remarque :
    par défaut la fonction se contente de remplacer les accents courants.
    avec les arguments optionnels, tout type de caractère peut être remplacé par tout autre, ou bien par rien du tout.
    Langage : C# 1.x , C# 2.x , ASP.NET 1.x , ASP.NET 2.x
    Date ajout : 27/08/2007
    Posté par fabrice69 [Liste]
    DateMAJ : 27/08/2007
           /// <summary>
            /// Delete all Accents
            /// </summary>
            /// <param name="txt">Source String with accents and special Char</param>
            /// <returns>Source String without accents and special Char</returns>
            private static string DeleteAccentAndSpecialsChar(string OriginalText)
            {
                string strTemp = OriginalText;
                // Regex creation
                Regex regA = new Regex("[ã|à|â|ä|á|å]");
                Regex regAA = new Regex("[Ã|À|Â|Ä|Á|Å]");
                Regex regE = new Regex("[é|è|ê|ë]");
                Regex regEE = new Regex("[É|È|Ê|Ë]");
                Regex regI = new Regex("[í|ì|î|ï]");
                Regex regII = new Regex("[Í|Ì|Î|Ï]");
                Regex regO = new Regex("[õ|ò|ó|ô|ö]");
                Regex regOO = new Regex("[Õ|Ó|Ò|Ô|Ö]");
                Regex regU = new Regex("[ù|ú|û|ü|µ]");
                Regex regUU = new Regex("[Ü|Ú|Ù|Û]");
                Regex regY = new Regex("[ý|ÿ]");
                Regex regYY = new Regex("[Ý]");
                Regex regAE = new Regex("[æ]");
                Regex regAEAE = new Regex("[Æ]");
                Regex regOE = new Regex("[œ]");
                Regex regOEOE = new Regex("[Œ]");
                Regex regC = new Regex("[ç]");
                Regex regCC = new Regex("[Ç]");
                Regex regDD = new Regex("[Ð]");
                Regex regN = new Regex("[ñ]");
                Regex regNN = new Regex("[Ñ]");
                Regex regS = new Regex("[š]");
                Regex regSS = new Regex("[Š]");
                strTemp = regA.Replace(strTemp, "a");
                strTemp = regAA.Replace(strTemp, "A");
                strTemp = regE.Replace(strTemp, "e");
                strTemp = regEE.Replace(strTemp, "E");
                strTemp = regI.Replace(strTemp, "i");
                strTemp = regII.Replace(strTemp, "I");
                strTemp = regO.Replace(strTemp, "o");
                strTemp = regOO.Replace(strTemp, "O");
                strTemp = regU.Replace(strTemp, "u");
                strTemp = regUU.Replace(strTemp, "U");
                strTemp = regY.Replace(strTemp, "y");
                strTemp = regYY.Replace(strTemp, "Y");
                strTemp = regAE.Replace(strTemp, "ae");
                strTemp = regAEAE.Replace(strTemp, "AE");
                strTemp = regOE.Replace(strTemp, "oe");
                strTemp = regOEOE.Replace(strTemp, "OE");
                strTemp = regC.Replace(strTemp, "c");
                strTemp = regCC.Replace(strTemp, "C");
                strTemp = regDD.Replace(strTemp, "D");
                strTemp = regN.Replace(strTemp, "n");
                strTemp = regNN.Replace(strTemp, "N");
                strTemp = regS.Replace(strTemp, "s");
                strTemp = regSS.Replace(strTemp, "S");
                return strTemp;
    
                return strTemp;
            }
    
    Remarque :
    Fonctionnement en C# pour tous les caractères spéciaux
    Langage : Delphi 5
    Date ajout : 10/09/2007
    Posté par cirec [Liste]
    Function RemoveAccent(Const S : String): String;
    Const
      ATC : Array[$C0..$DF] Of Byte = ($41,$41,$41,$41,$41,$41,$41,$43,$45,$45,$45,
       $45,$49,$49,$49,$49,$44,$4E,$4F,$4F,$4F,$4F,$4F,$4F,$4F,$55,$55,$55,$55,$59,$42,$59);
    Var P, PR : PByte;
        Size  : Integer;
    Begin
      P    := PByte(S);
      Size := Length(S);
      SetLength(Result, Size);
      PR   := PByte(Result);
      While P^ <> $0 do Begin
        If P^ > $7A Then
        Case P^ Of
          $8A : Pr^ := $53;
          $8E : Pr^ := $5A;
          $9E : Pr^ := $7A;
          $9F : Pr^ := $59;
          $C0..$DF  : Pr^ := ATC[P^];  
          $E0..$FF  : Pr^ := ATC[P^ Xor $20] Xor $20;  
          Else Pr^ := P^;
        End Else Pr^ := P^;
        Inc(P);
        Inc(Pr);
      End;                  
    End;
    
    

    Snippets en rapport avec : Caractères, Spéciaux



    Codes sources en rapport avec : Caractères, Spéciaux

    {Javascript / DHTML} CONVERSION TEXTE ACCENTUÉ -> CODE HTML
    Etant donné que je n'ai pas trouvé de code qui permettait de me générer un code HTML à partir d'un t...

    {Delphi} CONVERTIR LES CODE HTML EN CARACTÈRES SPÉCIAUX
    Voici le complément à la source poster par Japee : http://www.delphifr.com/codes/CONVERTIR-CARACTE...

    {PHP} CONVERSION DES CARACTÈRES SPÉCIAUX DANS UNE BASE DE DONNÉES MYSQL
    Ce script convertit les caractères spéciaux tel que les simple quote ou les accents ... dans tous le...

    {Delphi} CONVERTIR LES CARACTÈRES SPÉCIAUX EN CODE HTML [TEXT TO HTML]
    Conversion des caractères spéciaux vers leur équivalent en code html. Ce code (simplifié) est ext...

    {Delphi} VFONTS : OUTIL DE VISUALISATION DES POLICES CARACTÈRES INSTALLÉES - RECHERCHES, CRÉATION DE SÉLECTION MÉMORISÉES, AIDE COMPLÈTE EN FRANÇAIS.
    Ce petit logiciel, sous licence GPL, est destiné à vous aider à choisir certaines polices de caractè...

    {C / C++ / C++.NET} [C/WIN32] GÉNÉRATEUR DE CODE POUR UNE INITIALISATION SPÉCIALE DE CHAINE DE CARACTÈRES.
    Yop, Voici BNMgenerator, à comprendre BruNews Method Generator. J'espère qu'il me pardonnera ce n...

    {PHP} FORMATAGE AUTOMATIQUE D'UN TEXT EN FONCTION DE MOTS CLÉES
    Je cherchais depuis quelque temps un script me permettant de souligner, ou mettre en gras certain mo...

    {Visual Basic, VB6, VB.NET, VB 2005} LIMITER LA FRAPPE DANS DES ZONES COMBO OU TEXT À DES CHIFFRES
    Il s'agit d'une petite mise à jour pour VB.NET des astuces déjà existantes pour VB5 et VB6 qui avaie...

    {Visual Basic, VB6, VB.NET, VB 2005} RECHERCHE DE CHAINE DE CARACTÉRES SUR DES FICHIERS .TXT AVEC SÉPARATEURS ENTRE LES CHAMPS, ET AFFICHAGE AVEC ALIGNEMENT DES ZONES.
    Ce programme sert à 'RAPIDEMENT' chercher et afficher des lignes d'enregistrements d'un fichier de t...

    {PHP} INTERDIRE CERTAINS CARACTÈRES
    Bonjour a tous, Cette source permet d'interdire l'utilisation de certains caractère et d'afficher u...