How do I remove diacritics (accents) from a string in .NET?

前端 未结 20 2948
南方客
南方客 2020-11-21 05:44

I\'m trying to convert some strings that are in French Canadian and basically, I\'d like to be able to take out the French accent marks in the letters while keeping the lett

20条回答
  •  我寻月下人不归
    2020-11-21 05:59

    Imports System.Text
    Imports System.Globalization
    
     Public Function DECODE(ByVal x As String) As String
            Dim sb As New StringBuilder
            For Each c As Char In x.Normalize(NormalizationForm.FormD).Where(Function(a) CharUnicodeInfo.GetUnicodeCategory(a) <> UnicodeCategory.NonSpacingMark)  
                sb.Append(c)
            Next
            Return sb.ToString()
        End Function
    

提交回复
热议问题