Android Code Snippet Remove accents from string

Discussion in 'Code Snippets' started by Erel, Apr 29, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    SubName: RemoveAccents

    Description: Removes the accents and returns a new string

    Sub Activity_Create(FirstTime As Boolean)
    Log(RemoveAccents("áóúñéí")) 'prints aounei
    End Sub

    Sub RemoveAccents(s As StringAs String
    Dim normalizer As JavaObject
    Dim n As String = normalizer.RunMethod("normalize"Array As Object(s, "NFD"))
    Dim sb As StringBuilder
    For i = 0 To n.Length - 1
    If Regex.IsMatch("\p{InCombiningDiacriticalMarks}", n.CharAt(i)) = False  Then
    End If
    Return sb.ToString
    End Sub
    Tags: string accents

    Based on this link:
    arastoo, jmon, NeoTechni and 3 others like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice