Beispiel #1
0
        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);
        }