Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7
Expertise: beginner
Aug 18, 2003

ReplaceAccentedChars - Replacing all accented characters in the input string

' Replace all accented characters in the input string
' Note: this function was written according to Italian rules. Rules for your 
' language may vary, for example È may not be converted to "E'" as it is in 
' Italian
' 
' Example:
'   Debug.WriteLine(ReplaceAccentedChars("È vero che funziona? Certo che lo è, 
' non può non funzionare"))
'     ' => E' vero che funziona? Certo che lo e', non puo' non funzionare

Function ReplaceAccentedChars(ByVal input As String) As String
    input = input.Replace("À", "A")
    input = input.Replace("Á", "A")
    input = input.Replace("Â", "A")
    input = input.Replace("Ã", "A")
    input = input.Replace("Ä", "A")
    input = input.Replace("â", "a")
    input = input.Replace("ã", "a")
    input = input.Replace("ä", "a")
    input = input.Replace("à", "a'")
    input = input.Replace("á", "a'")

    input = input.Replace("È", "E'")
    input = input.Replace("É", "E'")
    input = input.Replace("Ê", "E")
    input = input.Replace("Ë", "E")
    input = input.Replace("ê", "e")
    input = input.Replace("ë", "e")
    input = input.Replace("è", "e'")
    input = input.Replace("é", "e'")

    input = input.Replace("Ì", "I")
    input = input.Replace("Í", "I")
    input = input.Replace("Î", "I")
    input = input.Replace("Ï", "I")
    input = input.Replace("î", "i")
    input = input.Replace("ï", "i")
    input = input.Replace("ì", "i'")
    input = input.Replace("í", "i'")

    input = input.Replace("Ò", "O")
    input = input.Replace("Ó", "O")
    input = input.Replace("Ô", "O")
    input = input.Replace("Õ", "O")
    input = input.Replace("Ö", "O")
    input = input.Replace("ô", "o")
    input = input.Replace("õ", "o")
    input = input.Replace("ö", "o")
    input = input.Replace("ò", "o'")
    input = input.Replace("ó", "o'")

    input = input.Replace("Ù", "U")
    input = input.Replace("Ú", "U")
    input = input.Replace("Û", "U")
    input = input.Replace("Ü", "U")
    input = input.Replace("û", "u")
    input = input.Replace("ü", "u")
    input = input.Replace("ù", "u'")
    input = input.Replace("ú", "u'")

    input = input.Replace("Ý", "Y")
    input = input.Replace("ý", "y")
    input = input.Replace("ñ", "n")

    Return input
End Function
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date