Last active
June 9, 2016 19:31
-
-
Save cuongdev/465e1c788882b361253795b5b09b5ed2 to your computer and use it in GitHub Desktop.
Remove VietNameseSign using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string VietnameseSigns(string str) | |
{ | |
str = str.Trim(); | |
var charsToRemove = new string[] { "@", ",", ".", ";", "'", "/", "\\", "\"", "[", "]","#","+" }; | |
foreach (var c in charsToRemove) | |
{ | |
str = str.Replace(c, string.Empty); | |
} | |
const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ "; | |
const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY-"; | |
int index = -1; | |
char[] arrChar = FindText.ToCharArray(); | |
while ((index = str.IndexOfAny(arrChar)) != -1) | |
{ | |
int index2 = FindText.IndexOf(str[index]); | |
str = str.Replace(str[index], ReplText[index2]); | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment