Chân thành cảm ơn bạn FlyingFox một lần nữa.
Mình có thêm được một tý mã nữa để loại bỏ ký tự [tab] bằng cách thêm stFormD[i] == '\t'.
Chúc bạn nhiều sức khỏe và thành công trong cuộc sống.
Code:
public string RemoveUnicode(string inputText)
{
string stFormD = inputText.Normalize(System.Text.NormalizationForm.FormD);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string str = "";
for (int i = 0; i <= stFormD.Length - 1; i++)
{
UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[i]);
if (uc == UnicodeCategory.NonSpacingMark == false)
{
if (stFormD[i] == 'đ')
str = "d";
else if (stFormD[i] == 'Đ')
str = "D";
else if (stFormD[i] == '\r' | stFormD[i] == '\n' | stFormD[i] == '\t')
str = "";
else
str = stFormD[i].ToString();
sb.Append(str);
}
}
return sb.ToString();
}