SubName: RemoveAccents
Description: Removes the accents and returns a new string
Tags: string accents
Based on this link: http://stackoverflow.com/questions/5697171/regex-what-is-incombiningdiacriticalmarks
Description: Removes the accents and returns a new string
B4X:
Sub Activity_Create(FirstTime As Boolean)
Log(RemoveAccents("áóúñéí")) 'prints aounei
End Sub
Sub RemoveAccents(s As String) As String
Dim normalizer As JavaObject
normalizer.InitializeStatic("java.text.Normalizer")
Dim n As String = normalizer.RunMethod("normalize", Array As Object(s, "NFD"))
Dim sb As StringBuilder
sb.Initialize
For i = 0 To n.Length - 1
If Regex.IsMatch("\p{InCombiningDiacriticalMarks}", n.CharAt(i)) = False Then
sb.Append(n.CharAt(i))
End If
Next
Return sb.ToString
End Sub
Tags: string accents
Based on this link: http://stackoverflow.com/questions/5697171/regex-what-is-incombiningdiacriticalmarks