C#: Đoạn code chuyển tiếng Việt có dấu thành tiếng Việt không dấu



Ví dụ: C# là ngôn ngữ tuyệt vời nhất. Java, PHP, C, C++, Ruby chỉ toàn là thứ rẻ tiền => sau khi gọi hàm:C-la-ngon-ngu-tuyet-voi-nhat-Java-PHP-C-C-Ruby-chi-toan-la-thu-re-tien

public string LoaiDau(string str)
{
Regex regex = new Regex("\\p{IsCombiningDiacriticalMarks}+");
string temp = str.Normalize(NormalizationForm.FormD);
return regex.Replace(temp, String.Empty)
.Replace('đ', 'd').Replace('Đ', 'D');
}
Source Code: https://goo.gl/kA5ysR

Video hướng dẫn làm:

Bài liên quan

Bài liên quan