Removing/replacing international characters

前端 未结 2 1829
栀梦
栀梦 2021-01-01 02:31

I am creating a small app in C# to search for filenames based on information passed from a SQL query. Within the data passed from the SQL query there will be on occasion (po

相关标签:
2条回答
  • 2021-01-01 02:42
    var s1 = ToASCII("Hervé");
    var s2 = ToASCII("Mañana"); 
    
    string ToASCII(string s)
    {
        return String.Join("",
             s.Normalize(NormalizationForm.FormD)
            .Where(c => char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark));
    }
    
    0 讨论(0)
  • 2021-01-01 02:46

    If you're running against MS-SQL server, see COLLATE in the online help. You can functionally change the encoding on the fly.

    0 讨论(0)
提交回复
热议问题