Esempio n. 1
0
    public static string LocDauFileName(string txt)
    {
        txt = txt.ToLower();
        txt = HttpUtility.HtmlDecode(txt);
        const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
        const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY";
        int          index    = -1;

        char[] arrChar = FindText.ToCharArray();
        while ((index = txt.IndexOfAny(arrChar)) != -1)
        {
            int index2 = FindText.IndexOf(txt[index]);
            txt = txt.Replace(txt[index], ReplText[index2]);
        }
        txt = txt.Replace(" ", "-");
        txt = txt.Replace("|", "");
        txt = txt.Replace("?", "");
        txt = txt.Replace("'", "");
        txt = txt.Replace("\"", "");
        txt = txt.Replace(":", "");
        txt = txt.Replace(";", "");
        txt = txt.Replace(",", "");
        txt = txt.Replace("&", "");
        txt = txt.Replace("=", "");
        txt = txt.Replace("/-+-/g", "");
        txt = txt.Replace(@"/^\-+|\-+$/g", "");
        txt = txt.Replace(@"/ \ ?", "");
        txt = txt.Replace("(", "");
        txt = txt.Replace(")", "");
        txt = txt.Replace("%", "");
        txt = txt.Replace("\"", "");
        return(txt);
    }
Esempio n. 2
0
 public static string ConvertToUsignNew(string s)
 {
     const string FindText = "áàảãạâấầẩẫậăắằẳẵặDéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶDÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
     const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY";
     int index = -1;
     char[] arrChar = FindText.ToCharArray();
     while ((index = s.IndexOfAny(arrChar)) != -1)
     {
         int index2 = FindText.IndexOf(s[index]);
         s = s.Replace(s[index], ReplText[index2]);
     }
     return s;
 }
Esempio n. 3
0
        /// <summary>
        /// Chuyển tiếng việt có dấu thành tiếng việt không dấu
        /// </summary>
        /// <param name="strVietnamese">tiếng việt có dấu</param>
        /// <returns>tiếng việt không dấu</returns>
        public static string ConvertToVietnameseNotSignature2(string strVietnamese)
        {
            const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ#%&*:|.";
            const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY       ";
            int          index    = -1;

            while ((index = strVietnamese.IndexOfAny(FindText.ToCharArray())) != -1)
            {
                int index2 = FindText.IndexOf(strVietnamese[index]);
                strVietnamese = strVietnamese.Replace(strVietnamese[index], ReplText[index2]);
            }
            return(strVietnamese);
        }
Esempio n. 4
0
 //----------------------------------------------------------
 public string RemoveUnicode(string text)
 {
     const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
     const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY";
     int index = -1;
     char[] arrChar = FindText.ToCharArray();
     while ((index = text.IndexOfAny(arrChar)) != -1)
     {
         int index2 = FindText.IndexOf(text[index]);
         text = text.Replace(text[index], ReplText[index2]);
     }
     return text;
 }
Esempio n. 5
0
        public static string ChuyenTiengVietKhongDau(string text)
        {
            const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ #%&*:|.";
            const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY-       ";
            int          index    = -1;

            while ((index = text.IndexOfAny(FindText.ToCharArray())) != -1)
            {
                int index2 = FindText.IndexOf(text[index]);
                text = text.Replace(text[index], ReplText[index2]);
            }
            return(text);
        }
Esempio n. 6
0
        public static string RemoveVietnameseChars(string source)
        {
            var          result   = source;
            int          index    = -1;
            const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
            const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY";

            char[] arrChar = FindText.ToCharArray();
            while ((index = result.IndexOfAny(arrChar)) != -1)
            {
                int index2 = FindText.IndexOf(result[index]);
                result = result.Replace(result[index], ReplText[index2]);
            }
            return(result);
        }
        public static bool CheckVietKey(string chuCoDau)
        {
            const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
            int          n;
            int          m = chuCoDau.Length;

            char[] arrS = chuCoDau.ToCharArray();
            for (int i = 0; i < m; i++)
            {
                n = FindText.IndexOf(arrS[i]);
                if (n != -1)
                {
                    return(true);          //Tìm thấy kí tự có dấu trong dãy FindText
                }
            }
            return(false);    //Không tìm thấy kí tự có dấu
        }
Esempio n. 8
0
        public static string ConvertAliasVN(string chuoicodau)
        {
            if (string.IsNullOrEmpty(chuoicodau))
            {
                return("");
            }
            const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
            const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY";
            int          index    = -1;

            char[] arrChar = FindText.ToCharArray();
            while ((index = chuoicodau.IndexOfAny(arrChar)) != -1)
            {
                int index2 = FindText.IndexOf(chuoicodau[index]);
                chuoicodau = chuoicodau.Replace(chuoicodau[index], ReplText[index2]);
            }
            return(chuoicodau.ToLower());
        }
Esempio n. 9
0
 public static string ConvertToNoSign(string strValue)
 {
     try
     {
         const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ";
         const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY";
         int          index    = -1;
         char[]       arrChar  = FindText.ToCharArray();
         while ((index = strValue.IndexOfAny(arrChar)) != -1)
         {
             int index2 = FindText.IndexOf(strValue[index]);
             strValue = strValue.Replace(strValue[index], ReplText[index2]);
         }
         return(strValue);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 10
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);
        }