为大家分享一下个人的一个Utils系统帮助类,可能有些现在有新的技术替代,自行修改哈~
这个帮助类主要包含:对象转换处理 、分割字符串、截取字符串、删除最后结尾的一个逗号、 删除最后结尾的指定字符后的字符、 生成指定长度的字符串、 生成日期随机码、 生成随机字母或数、字 截取字符长度、 对象<-->JSON 4.0使用、 对象<-->JSON 2.0使用litjson插件、 DataTable<-->JSON、 List<--->DataTable、 清除HTML标记、 清除HTML标记且返回相应的长度、 TXT代码转换成HTML格式、 HTML代码转换成TXT格式、 检测是否有Sql危险字符、 过滤特殊字符、 检查是否为IP地址、 获得配置文件节点XML文件的绝对路径、 获得当前绝对路径、 文件操作、 读取或写入cookie 替换指定的字符串、 URL处理、 MD5加密方法、 获得当前页面客户端的IP、 数据导出为EXCEL、 列的命名、 构造URL POST请求、 构造URL GET请求、 POST请求、 访问提交创建文件 (供生成静态页面使用,无需模板)、 汉字转拼音、 获取网页的HTML内容
废话不多说,上代码:
对象转换处理
class="code_img_closed" src="/Upload/Images/2016051205/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('6503e529-de03-466e-ac2a-f464bda1733d',event)" src="/Upload/Images/2016051205/2B1B950FA3DF188F.gif" alt="" />
1 #region 对象转换处理 2 /// <summary> 3 /// 判断对象是否为Int32类型的数字 4 /// </summary> 5 /// <param name="Expression"></param> 6 /// <returns></returns> 7 public static bool IsNumeric(object expression) 8 { 9 if (expression != null) 10 return IsNumeric(expression.ToString()); 11 12 return false; 13 14 } 15 16 /// <summary> 17 /// 判断对象是否为Int32类型的数字 18 /// </summary> 19 /// <param name="Expression"></param> 20 /// <returns></returns> 21 public static bool IsNumeric(string expression) 22 { 23 if (expression != null) 24 { 25 string str = expression; 26 if (str.Length > 0 && str.Length <= 11 && Regex.IsMatch(str, @"^[-]?[0-9]*[.]?[0-9]*$")) 27 { 28 if ((str.Length < 10) || (str.Length == 10 && str[0] == '1') || (str.Length == 11 && str[0] == '-' && str[1] == '1')) 29 return true; 30 } 31 } 32 return false; 33 } 34 35 /// <summary> 36 /// 是否为Double类型 37 /// </summary> 38 /// <param name="expression"></param> 39 /// <returns></returns> 40 public static bool IsDouble(object expression) 41 { 42 if (expression != null) 43 return Regex.IsMatch(expression.ToString(), @"^([0-9])[0-9]*(\.\w*)?$"); 44 45 return false; 46 } 47 48 /// <summary> 49 /// 将字符串转换为数组 50 /// </summary> 51 /// <param name="str">字符串</param> 52 /// <returns>字符串数组</returns> 53 public static string[] GetStrArray(string str) 54 { 55 return str.Split(new char[',']); 56 } 57 58 /// <summary> 59 /// 将数组转换为字符串 60 /// </summary> 61 /// <param name="list">List</param> 62 /// <param name="speater">分隔符</param> 63 /// <returns>String</returns> 64 public static string GetArrayStr(List<string> list, string speater) 65 { 66 StringBuilder sb = new StringBuilder(); 67 for (int i = 0; i < list.Count; i++) 68 { 69 if (i == list.Count - 1) 70 { 71 sb.Append(list[i]); 72 } 73 else 74 { 75 sb.Append(list[i]); 76 sb.Append(speater); 77 } 78 } 79 return sb.ToString(); 80 } 81 82 /// <summary> 83 /// object型转换为bool型 84 /// </summary> 85 /// <param name="strValue">要转换的字符串</param> 86 /// <param name="defValue">缺省值</param> 87 /// <returns>转换后的bool类型结果</returns> 88 public static bool StrToBool(object expression, bool defValue) 89 { 90 if (expression != null) 91 return StrToBool(expression, defValue); 92 93 return defValue; 94 } 95 96 /// <summary> 97 /// string型转换为bool型 98 /// </summary> 99 /// <param name="strValue">要转换的字符串</param> 100 /// <param name="defValue">缺省值</param> 101 /// <returns>转换后的bool类型结果</returns> 102 public static bool StrToBool(string expression, bool defValue) 103 { 104 if (expression != null) 105 { 106 if (string.Compare(expression, "true", true) == 0) 107 return true; 108 else if (string.Compare(expression, "false", true) == 0) 109 return false; 110 } 111 return defValue; 112 } 113 114 /// <summary> 115 /// 将对象转换为Int32类型 116 /// </summary> 117 /// <param name="expression">要转换的字符串</param> 118 /// <param name="defValue">缺省值</param> 119 /// <returns>转换后的int类型结果</returns> 120 public static int ObjToInt(object expression, int defValue) 121 { 122 if (expression != null) 123 return StrToInt(expression.ToString(), defValue); 124 125 return defValue; 126 } 127 128 /// <summary> 129 /// 将字符串转换为Int32类型 130 /// </summary> 131 /// <param name="expression">要转换的字符串</param> 132 /// <param name="defValue">缺省值</param> 133 /// <returns>转换后的int类型结果</returns> 134 public static int StrToInt(string expression, int defValue) 135 { 136 if (string.IsNullOrEmpty(expression) || expression.Trim().Length >= 11 || !Regex.IsMatch(expression.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$")) 137 return defValue; 138 139 int rv; 140 if (Int32.TryParse(expression, out rv)) 141 return rv; 142 143 return Convert.ToInt32(StrToFloat(expression, defValue)); 144 } 145 146 /// <summary> 147 /// Object型转换为decimal型 148 /// </summary> 149 /// <param name="strValue">要转换的字符串</param> 150 /// <param name="defValue">缺省值</param> 151 /// <returns>转换后的decimal类型结果</returns> 152 public static decimal ObjToDecimal(object expression, decimal defValue) 153 { 154 if (expression != null) 155 return StrToDecimal(expression.ToString(), defValue); 156 157 return defValue; 158 } 159 160 /// <summary> 161 /// string型转换为decimal型 162 /// </summary> 163 /// <param name="strValue">要转换的字符串</param> 164 /// <param name="defValue">缺省值</param> 165 /// <returns>转换后的decimal类型结果</returns> 166 public static decimal StrToDecimal(string expression, decimal defValue) 167 { 168 if ((expression == null) || (expression.Length > 10)) 169 return defValue; 170 171 decimal intValue = defValue; 172 if (expression != null) 173 { 174 bool IsDecimal = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$"); 175 if (IsDecimal) 176 decimal.TryParse(expression, out intValue); 177 } 178 return intValue; 179 } 180 181 /// <summary> 182 /// Object型转换为float型 183 /// </summary> 184 /// <param name="strValue">要转换的字符串</param> 185 /// <param name="defValue">缺省值</param> 186 /// <returns>转换后的int类型结果</returns> 187 public static float ObjToFloat(object expression, float defValue) 188 { 189 if (expression != null) 190 return StrToFloat(expression.ToString(), defValue); 191 192 return defValue; 193 } 194 195 /// <summary> 196 /// string型转换为float型 197 /// </summary> 198 /// <param name="strValue">要转换的字符串</param> 199 /// <param name="defValue">缺省值</param> 200 /// <returns>转换后的int类型结果</returns> 201 public static float StrToFloat(string expression, float defValue) 202 { 203 if ((expression == null) || (expression.Length > 10)) 204 return defValue; 205 206 float intValue = defValue; 207 if (expression != null) 208 { 209 bool IsFloat = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$"); 210 if (IsFloat) 211 float.TryParse(expression, out intValue); 212 } 213 return intValue; 214 } 215 216 /// <summary> 217 /// 将对象转换为日期时间类型 218 /// </summary> 219 /// <param name="str">要转换的字符串</param> 220 /// <param name="defValue">缺省值</param> 221 /// <returns>转换后的int类型结果</returns> 222 public static DateTime StrToDateTime(string str, DateTime defValue) 223 { 224 if (!string.IsNullOrEmpty(str)) 225 { 226 DateTime dateTime; 227 if (DateTime.TryParse(str, out dateTime)) 228 return dateTime; 229 } 230 return defValue; 231 } 232 233 /// <summary> 234 /// 将对象转换为日期时间类型 235 /// </summary> 236 /// <param name="str">要转换的字符串</param> 237 /// <returns>转换后的int类型结果</returns> 238 public static DateTime StrToDateTime(string str) 239 { 240 return StrToDateTime(str, DateTime.Now); 241 } 242 243 /// <summary> 244 /// 将对象转换为日期时间类型 245 /// </summary> 246 /// <param name="obj">要转换的对象</param> 247 /// <returns>转换后的int类型结果</returns> 248 public static DateTime ObjectToDateTime(object obj) 249 { 250 return StrToDateTime(obj.ToString()); 251 } 252 253 /// <summary> 254 /// 将对象转换为日期时间类型 255 /// </summary> 256 /// <param name="obj">要转换的对象</param> 257 /// <param name="defValue">缺省值</param> 258 /// <returns>转换后的int类型结果</returns> 259 public static DateTime ObjectToDateTime(object obj, DateTime defValue) 260 { 261 return StrToDateTime(obj.ToString(), defValue); 262 } 263 264 /// <summary> 265 /// 将对象转换为字符串 266 /// </summary> 267 /// <param name="obj">要转换的对象</param> 268 /// <returns>转换后的string类型结果</returns> 269 public static string ObjectToStr(object obj) 270 { 271 if (obj == null) 272 return ""; 273 return obj.ToString().Trim(); 274 } 275 #endregionView Code
分割字符串
1 #region 分割字符串 2 /// <summary> 3 /// 分割字符串 4 /// </summary> 5 public static string[] SplitString(string strContent, string strSplit) 6 { 7 if (!string.IsNullOrEmpty(strContent)) 8 { 9 if (strContent.IndexOf(strSplit) < 0) 10 return new string[] { strContent }; 11 12 return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase); 13 } 14 else 15 return new string[0] { }; 16 } 17 18 /// <summary> 19 /// 分割字符串 20 /// </summary> 21 /// <returns></returns> 22 public static string[] SplitString(string strContent, string strSplit, int count) 23 { 24 string[] result = new string[count]; 25 string[] splited = SplitString(strContent, strSplit); 26 27 for (int i = 0; i < count; i++) 28 { 29 if (i < splited.Length) 30 result[i] = splited[i]; 31 else 32 result[i] = string.Empty; 33 } 34 35 return result; 36 } 37 #endregionView Code
截取字符串
1 #region 截取字符串 2 public static string GetSubString(string p_SrcString, int p_Length, string p_TailString) 3 { 4 return GetSubString(p_SrcString, 0, p_Length, p_TailString); 5 } 6 public static string GetSubString(string p_SrcString, int p_StartIndex, int p_Length, string p_TailString) 7 { 8 string str = p_SrcString; 9 byte[] bytes = Encoding.UTF8.GetBytes(p_SrcString); 10 foreach (char ch in Encoding.UTF8.GetChars(bytes)) 11 { 12 if (((ch > '?') && (ch < '一')) || ((ch > 0xac00) && (ch < 0xd7a3))) 13 { 14 if (p_StartIndex >= p_SrcString.Length) 15 { 16 return ""; 17 } 18 return p_SrcString.Substring(p_StartIndex, ((p_Length + p_StartIndex) > p_SrcString.Length) ? (p_SrcString.Length - p_StartIndex) : p_Length); 19 } 20 } 21 if (p_Length < 0) 22 { 23 return str; 24 } 25 byte[] sourceArray = Encoding.Default.GetBytes(p_SrcString); 26 if (sourceArray.Length <= p_StartIndex) 27 { 28 return str; 29 } 30 int length = sourceArray.Length; 31 if (sourceArray.Length > (p_StartIndex + p_Length)) 32 { 33 length = p_Length + p_StartIndex; 34 } 35 else 36 { 37 p_Length = sourceArray.Length - p_StartIndex; 38 p_TailString = ""; 39 } 40 int num2 = p_Length; 41 int[] numArray = new int[p_Length]; 42 byte[] destinationArray = null; 43 int num3 = 0; 44 for (int i = p_StartIndex; i < length; i++) 45 { 46 if (sourceArray[i] > 0x7f) 47 { 48 num3++; 49 if (num3 == 3) 50 { 51 num3 = 1; 52 } 53 } 54 else 55 { 56 num3 = 0; 57 } 58 numArray[i] = num3; 59 } 60 if ((sourceArray[length - 1] > 0x7f) && (numArray[p_Length - 1] == 1)) 61 { 62 num2 = p_Length + 1; 63 } 64 destinationArray = new byte[num2]; 65 Array.Copy(sourceArray, p_StartIndex, destinationArray, 0, num2); 66 return (Encoding.Default.GetString(destinationArray) + p_TailString); 67 } 68 #endregionView Code
删除最后结尾的一个逗号
1 #region 删除最后结尾的一个逗号 2 /// <summary> 3 /// 删除最后结尾的一个逗号 4 /// </summary> 5 public static string DelLastComma(string str) 6 { 7 return str.Substring(0, str.LastIndexOf(",")); 8 } 9 #endregionView Code
删除最后结尾的指定字符后的字符
1 #region 删除最后结尾的指定字符后的字符 2 /// <summary> 3 /// 删除最后结尾的指定字符后的字符 4 /// </summary> 5 public static string DelLastChar(string str, string strchar) 6 { 7 if (string.IsNullOrEmpty(str)) 8 return ""; 9 if (str.LastIndexOf(strchar) >= 0 && str.LastIndexOf(strchar) == str.Length - 1) 10 { 11 return str.Substring(0, str.LastIndexOf(strchar)); 12 } 13 return str; 14 } 15 #endregionView Code
生成指定长度的字符串
1 #region 生成指定长度的字符串 2 /// <summary> 3 /// 生成指定长度的字符串,即生成strLong个str字符串 4 /// </summary> 5 /// <param name="strLong">生成的长度</param> 6 /// <param name="str">以str生成字符串</param> 7 /// <returns></returns> 8 public static string StringOfChar(int strLong, string str) 9 { 10 string ReturnStr = ""; 11 for (int i = 0; i < strLong; i++) 12 { 13 ReturnStr += str; 14 } 15 16 return ReturnStr; 17 } 18 #endregionView Code
生成日期随机码
1 #region 生成日期随机码 2 /// <summary> 3 /// 生成日期随机码 4 /// </summary> 5 /// <returns></returns> 6 public static string GetRamCode() 7 { 8 #region 9 return DateTime.Now.ToString("yyyyMMddHHmmssffff"); 10 #endregion 11 } 12 #endregionView Code
生成随机字母或数字
1 #region 生成随机字母或数字 2 /// <summary> 3 /// 生成随机数字 4 /// </summary> 5 /// <param name="length">生成长度</param> 6 /// <returns></returns> 7 public static string Number(int Length) 8 { 9 return Number(Length, false); 10 } 11 12 /// <summary> 13 /// 生成随机数字 14 /// </summary> 15 /// <param name="Length">生成长度</param> 16 /// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param> 17 /// <returns></returns> 18 public static string Number(int Length, bool Sleep) 19 { 20 if (Sleep) 21 System.Threading.Thread.Sleep(3); 22 string result = ""; 23 System.Random random = new Random(); 24 for (int i = 0; i < Length; i++) 25 { 26 result += random.Next(10).ToString(); 27 } 28 return result; 29 } 30 /// <summary> 31 /// 生成随机字母字符串(数字字母混和) 32 /// </summary> 33 /// <param name="codeCount">待生成的位数</param> 34 public static string GetCheckCode(int codeCount) 35 { 36 string str = string.Empty; 37 int rep = 0; 38 long num2 = DateTime.Now.Ticks + rep; 39 rep++; 40 Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> rep))); 41 for (int i = 0; i < codeCount; i++) 42 { 43 char ch; 44 int num = random.Next(); 45 if ((num % 2) == 0) 46 { 47 ch = (char)(0x30 + ((ushort)(num % 10))); 48 } 49 else 50 { 51 ch = (char)(0x41 + ((ushort)(num % 0x1a))); 52 } 53 str = str + ch.ToString(); 54 } 55 return str; 56 } 57 /// <summary> 58 /// 根据日期和随机码生成订单号 59 /// </summary> 60 /// <returns></returns> 61 public static string GetOrderNumber() 62 { 63 string num = DateTime.Now.ToString("yyMMddHHmmss");//yyyyMMddHHmmssms 64 return num + Number(2).ToString(); 65 } 66 private static int Next(int numSeeds, int length) 67 { 68 byte[] buffer = new byte[length]; 69 System.Security.Cryptography.RNGCryptoServiceProvider Gen = new System.Security.Cryptography.RNGCryptoServiceProvider(); 70 Gen.GetBytes(buffer); 71 uint randomResult = 0x0;//这里用uint作为生成的随机数 72 for (int i = 0; i < length; i++) 73 { 74 randomResult |= ((uint)buffer[i] << ((length - 1 - i) * 8)); 75 } 76 return (int)(randomResult % numSeeds); 77 } 78 #endregionView Code
截取字符长度
1 #region 截取字符长度 2 /// <summary> 3 /// 截取字符长度 4 /// </summary> 5 /// <param name="inputString">字符</param> 6 /// <param name="len">长度</param> 7 /// <returns></returns> 8 public static string CutString(string inputString, int len) 9 { 10 if (string.IsNullOrEmpty(inputString)) 11 return ""; 12 inputString = DropHTML(inputString); 13 ASCIIEncoding ascii = new ASCIIEncoding(); 14 int tempLen = 0; 15 string tempString = ""; 16 byte[] s = ascii.GetBytes(inputString); 17 for (int i = 0; i < s.Length; i++) 18 { 19 if ((int)s[i] == 63) 20 { 21 tempLen += 2; 22 } 23 else 24 { 25 tempLen += 1; 26 } 27 28 try 29 { 30 tempString += inputString.Substring(i, 1); 31 } 32 catch 33 { 34 break; 35 } 36 37 if (tempLen > len) 38 break; 39 } 40 //如果截过则加上半个省略号 41 byte[] mybyte = System.Text.Encoding.Default.GetBytes(inputString); 42 if (mybyte.Length > len) 43 tempString += "…"; 44 return tempString; 45 } 46 #endregionView Code
对象<-->JSON 4.0使用
1 #region 对象<-->JSON 4.0使用 2 /// <summary> 3 /// 对象转JSON 4 /// </summary> 5 /// <typeparam name="T">对象实体</typeparam> 6 /// <param name="t">内容</param> 7 /// <returns>json包</returns> 8 public static string ObjetcToJson<T>(T t) 9 { 10 try 11 { 12 DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(T)); 13 string szJson = ""; 14 using (MemoryStream stream = new MemoryStream()) 15 { 16 json.WriteObject(stream, t); 17 szJson = Encoding.UTF8.GetString(stream.ToArray()); 18 } 19 return szJson; 20 } 21 catch { return ""; } 22 } 23 24 /// <summary> 25 /// Json包转对象 26 /// </summary> 27 /// <typeparam name="T">对象</typeparam> 28 /// <param name="jsonstring">json包</param> 29 /// <returns>异常抛null</returns> 30 public static object JsonToObject<T>(string jsonstring) 31 { 32 object result = null; 33 try 34 { 35 DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(T)); 36 using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonstring))) 37 { 38 result = json.ReadObject(stream); 39 } 40 return result; 41 } 42 catch { return result; } 43 } 44 #endregionView Code
对象<-->JSON 2.0使用litjson插件
1 #region 对象<-->JSON 2.0 使用litjson插件 2 /// <summary> 3 /// 对象转JSON jsonData 4 /// </summary> 5 /// <typeparam name="T"></typeparam> 6 /// <param name="t"></param> 7 /// <returns></returns> 8 //public static string ObjetcToJsonData<T>(T t) 9 //{ 10 // try 11 // { 12 // JsonData json = new JsonData(t); 13 // return json.ToJson(); 14 // } 15 // catch 16 // { 17 // return ""; 18 // } 19 //} 20 21 ///// <summary> 22 ///// 对象转JSON jsonMapper 23 ///// </summary> 24 ///// <typeparam name="T"></typeparam> 25 ///// <param name="t"></param> 26 ///// <returns></returns> 27 //public static string ObjetcToJsonMapper<T>(T t) 28 //{ 29 // try 30 // { 31 // JsonData json = JsonMapper.ToJson(t); 32 // return json.ToJson(); 33 // } 34 // catch 35 // { 36 // return ""; 37 // } 38 //} 39 40 ///// <summary> 41 ///// json转对象 jsonMapper 42 ///// </summary> 43 ///// <param name="jsons"></param> 44 ///// <returns></returns> 45 //public static object JsonToObject(string jsons) 46 //{ 47 // try 48 // { 49 // JsonData jsonObject = JsonMapper.ToObject(jsons); 50 // return jsonObject; 51 // } 52 // catch { return null; } 53 //} 54 55 #endregionView Code
DataTable<-->JSON
1 #region DataTable<-->JSON 2 /// <summary> 3 /// DataTable转为json 4 /// </summary> 5 /// <param name="dt">DataTable</param> 6 /// <returns>json数据</returns> 7 public static string DataTableToJson(DataTable dt) 8 { 9 List<Dictionary<string, object>> list = new List<Dictionary<string, object>>(); 10 foreach (DataRow dr in dt.Rows) 11 { 12 Dictionary<string, object> result = new Dictionary<string, object>(); 13 foreach (DataColumn dc in dt.Columns) 14 { 15 result.Add(dc.ColumnName, dr[dc]); 16 } 17 list.Add(result); 18 } 19 20 return SerializeToJson(list); 21 } 22 /// <summary> 23 /// 序列化对象为Json字符串 24 /// </summary> 25 /// <param name="obj">要序列化的对象</param> 26 /// <param name="recursionLimit">序列化对象的深度,默认为100</param> 27 /// <returns>Json字符串</returns> 28 public static string SerializeToJson(object obj, int recursionLimit = 100) 29 { 30 try 31 { 32 JavaScriptSerializer serialize = new JavaScriptSerializer(); 33 serialize.RecursionLimit = recursionLimit; 34 return serialize.Serialize(obj); 35 } 36 catch { return ""; } 37 } 38 /// <summary> 39 /// json包转DataTable 40 /// </summary> 41 /// <param name="jsons"></param> 42 /// <returns></returns> 43 public static DataTable JsonToDataTable(string jsons) 44 { 45 DataTable dt = new DataTable(); 46 try 47 { 48 JavaScriptSerializer serialize = new JavaScriptSerializer(); 49 serialize.MaxJsonLength = Int32.MaxValue; 50 ArrayList list = serialize.Deserialize<ArrayList>(jsons); 51 if (list.Count > 0) 52 { 53 foreach (Dictionary<string, object> item in list) 54 { 55 if (item.Keys.Count == 0)//无值返回空 56 { 57 return dt; 58 } 59 if (dt.Columns.Count == 0)//初始Columns 60 { 61 foreach (string current in item.Keys) 62 { 63 dt.Columns.Add(current, item[current].GetType()); 64 } 65 } 66 DataRow dr = dt.NewRow(); 67 foreach (string current in item.Keys) 68 { 69 dr[current] = item[current]; 70 } 71 dt.Rows.Add(dr); 72 } 73 } 74 } 75 catch 76 { 77 return dt; 78 } 79 return dt; 80 } 81 #endregionView Code
List<--->DataTable
1 #region List<--->DataTable 2 /// <summary> 3 /// DataTable转换泛型集合 4 /// </summary> 5 /// <typeparam name="T"></typeparam> 6 /// <param name="table"></param> 7 /// <returns></returns> 8 public static List<T> DataTableToList<T>(DataTable table) 9 { 10 List<T> list = new List<T>(); 11 T t = default(T); 12 PropertyInfo[] propertypes = null; 13 string tempName = string.Empty; 14 foreach (DataRow row in table.Rows) 15 { 16 t = Activator.CreateInstance<T>(); 17 propertypes = t.GetType().GetProperties(); 18 foreach (PropertyInfo pro in propertypes) 19 { 20 tempName = pro.Name; 21 if (table.Columns.Contains(tempName)) 22 { 23 object value = row[tempName]; 24 if (!value.ToString().Equals("")) 25 { 26 pro.SetValue(t, value, null); 27 } 28 } 29 } 30 list.Add(t); 31 } 32 return list.Count == 0 ? null : list; 33 } 34 35 /// <summary> 36 /// 将集合类转换成DataTable 37 /// </summary> 38 /// <param name="list">集合</param> 39 /// <returns>DataTable</returns> 40 public static DataTable ListToDataTable(IList list) 41 { 42 DataTable result = new DataTable(); 43 if (list != null && list.Count > 0) 44 { 45 PropertyInfo[] propertys = list[0].GetType().GetProperties(); 46 foreach (PropertyInfo pi in propertys) 47 { 48 result.Columns.Add(pi.Name, pi.PropertyType); 49 } 50 for (int i = 0; i < list.Count; i++) 51 { 52 ArrayList tempList = new ArrayList(); 53 foreach (PropertyInfo pi in propertys) 54 { 55 object obj = pi.GetValue(list[i], null); 56 tempList.Add(obj); 57 } 58 object[] array = tempList.ToArray(); 59 result.LoadDataRow(array, true); 60 } 61 } 62 return result; 63 } 64 public static List<T> ConvertTo<T>(DataTable dt) where T : new() 65 { 66 if (dt == null) return null; 67 if (dt.Rows.Count <= 0) return null; 68 69 List<T> list = new List<T>(); 70 try 71 { 72 List<string> columnsName = new List<string>(); 73 foreach (DataColumn dataColumn in dt.Columns) 74 { 75 columnsName.Add(dataColumn.ColumnName);//得到所有的表头 76 } 77 list = dt.AsEnumerable().ToList().ConvertAll<T>(row => GetObject<T>(row, columnsName)); //转换 78 return list; 79 } 80 catch 81 { 82 return null; 83 } 84 } 85 86 public static T GetObject<T>(DataRow row, List<string> columnsName) where T : new() 87 { 88 T obj = new T(); 89 try 90 { 91 string columnname = ""; 92 string value = ""; 93 PropertyInfo[] Properties = typeof(T).GetProperties(); 94 foreach (PropertyInfo objProperty in Properties) //遍历T的属性 95 { 96 columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower()); //寻找可以匹配的表头名称 97 if (!string.IsNullOrEmpty(columnname)) 98 { 99 value = row[columnname].ToString(); 100 if (!string.IsNullOrEmpty(value)) 101 { 102 if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null) //存在匹配的表头 103 { 104 value = row[columnname].ToString().Replace("$", "").Replace(",", ""); //从dataRow中提取数据 105 objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())), null); //赋值操作 106 } 107 else 108 { 109 value = row[columnname].ToString().Replace("%", ""); //存在匹配的表头 110 objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);//赋值操作 111 } 112 } 113 } 114 } 115 return obj; 116 } 117 catch 118 { 119 return obj; 120 } 121 } 122 /// <summary> 123 /// 将泛型集合类转换成DataTable 124 /// </summary> 125 /// <typeparam name="T">集合项类型</typeparam> 126 /// <param name="list">集合</param> 127 /// <param name="propertyName">需要返回的列的列名</param> 128 /// <returns>数据集(表)</returns> 129 public static DataTable ListToDataTable<T>(IList<T> list, params string[] propertyName) 130 { 131 List<string> propertyNameList = new List<string>(); 132 if (propertyName != null) 133 propertyNameList.AddRange(propertyName); 134 DataTable result = new DataTable(); 135 if (list != null && list.Count > 0) 136 { 137 PropertyInfo[] propertys = list[0].GetType().GetProperties(); 138 foreach (PropertyInfo pi in propertys) 139 { 140 if (propertyNameList.Count == 0) 141 { 142 result.Columns.Add(pi.Name, pi.PropertyType); 143 } 144 else 145 { 146 if (propertyNameList.Contains(pi.Name)) 147 result.Columns.Add(pi.Name, pi.PropertyType); 148 } 149 } 150 for (int i = 0; i < list.Count; i++) 151 { 152 ArrayList tempList = new ArrayList(); 153 foreach (PropertyInfo pi in propertys) 154 { 155 if (propertyNameList.Count == 0) 156 { 157 object obj = pi.GetValue(list[i], null); 158 tempList.Add(obj); 159 } 160 else 161 { 162 if (propertyNameList.Contains(pi.Name)) 163 { 164 object obj = pi.GetValue(list[i], null); 165 tempList.Add(obj); 166 } 167 } 168 } 169 object[] array = tempList.ToArray(); 170 result.LoadDataRow(array, true); 171 } 172 } 173 return result; 174 } 175 176 #endregionView Code
清除HTML标记
1 #region 清除HTML标记 2 public static string DropHTML(string Htmlstring) 3 { 4 if (string.IsNullOrEmpty(Htmlstring)) return ""; 5 //删除脚本 6 Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); 7 //删除HTML 8 Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); 9 Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase); 10 Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase); 11 Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase); 12 Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase); 13 Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase); 14 Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase); 15 Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase); 16 Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase); 17 Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase); 18 Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase); 19 Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase); 20 Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase); 21 22 Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase); 23 Htmlstring.Replace("<", ""); 24 Htmlstring.Replace(">", ""); 25 Htmlstring.Replace("\r\n", ""); 26 Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim(); 27 return Htmlstring; 28 } 29 #endregionView Code
清除HTML标记且返回相应的长度
1 #region 清除HTML标记且返回相应的长度 2 public static string DropHTML(string Htmlstring, int strLen) 3 { 4 return CutString(DropHTML(Htmlstring), strLen); 5 } 6 #endregionView Code
TXT代码转换成HTML格式
1 #region TXT代码转换成HTML格式 2 /// <summary> 3 /// 字符串字符处理 4 /// </summary> 5 /// <param name="chr">等待处理的字符串</param> 6 /// <returns>处理后的字符串</returns> 7 /// //把TXT代码转换成HTML格式 8 public static String ToHtml(string Input) 9 { 10 StringBuilder sb = new StringBuilder(Input); 11 sb.Replace("&", "&"); 12 sb.Replace("<", "<"); 13 sb.Replace(">", ">"); 14 sb.Replace("\r\n", "<br />"); 15 sb.Replace("\n", "<br />"); 16 sb.Replace("\t", " "); 17 //sb.Replace(" ", " "); 18 return sb.ToString(); 19 } 20 #endregionView Code
HTML代码转换成TXT格式
1 #region HTML代码转换成TXT格式 2 /// <summary> 3 /// 字符串字符处理 4 /// </summary> 5 /// <param name="chr">等待处理的字符串</param> 6 /// <returns>处理后的字符串</returns> 7 /// //把HTML代码转换成TXT格式 8 public static String ToTxt(String Input) 9 { 10 StringBuilder sb = new StringBuilder(Input); 11 sb.Replace(" ", " "); 12 sb.Replace("<br>", "\r\n"); 13 sb.Replace("<br>", "\n"); 14 sb.Replace("<br />", "\n"); 15 sb.Replace("<br />", "\r\n"); 16 sb.Replace("<", "<"); 17 sb.Replace(">", ">"); 18 sb.Replace("&", "&"); 19 return sb.ToString(); 20 } 21 #endregionView Code
检测是否有Sql危险字符
1 #region 检测是否有Sql危险字符 2 /// <summary> 3 /// 检测是否有Sql危险字符 4 /// </summary> 5 /// <param name="str">要判断字符串</param> 6 /// <returns>判断结果</returns> 7 public static bool IsSafeSqlString(string str) 8 { 9 return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']"); 10 } 11 12 /// <summary> 13 /// 检查危险字符 14 /// </summary> 15 /// <param name="Input"></param> 16 /// <returns></returns> 17 public static string Filter(string sInput) 18 { 19 if (sInput == null || sInput == "") 20 return null; 21 string sInput1 = sInput.ToLower(); 22 string output = sInput; 23 string pattern = @"*|and|exec|insert|select|delete|update|count|master|truncate|declare|char(|mid(|chr(|'"; 24 if (Regex.Match(sInput1, Regex.Escape(pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase).Success) 25 { 26 throw new Exception("字符串中含有非法字符!"); 27 } 28 else 29 { 30 output = output.Replace("'", "''"); 31 } 32 return output; 33 } 34 35 /// <summary> 36 /// 检查过滤设定的危险字符 37 /// </summary> 38 /// <param name="InText">要过滤的字符串 </param> 39 /// <returns>如果参数存在不安全字符,则返回true </returns> 40 public static bool SqlFilter(string word, string InText) 41 { 42 if (InText == null) 43 return false; 44 foreach (string i in word.Split('|')) 45 { 46 if ((InText.ToLower().IndexOf(i + " ") > -1) || (InText.ToLower().IndexOf(" " + i) > -1)) 47 { 48 return true; 49 } 50 } 51 return false; 52 } 53 #endregionView Code
过滤特殊字符
1 #region 过滤特殊字符 2 /// <summary> 3 /// 过滤特殊字符 4 /// </summary> 5 /// <param name="Input"></param> 6 /// <returns></returns> 7 public static string Htmls(string Input) 8 { 9 if (Input != string.Empty && Input != null) 10 { 11 string ihtml = Input.ToLower(); 12 ihtml = ihtml.Replace("<script", "<script"); 13 ihtml = ihtml.Replace("script>", "script>"); 14 ihtml = ihtml.Replace("<%", "<%"); 15 ihtml = ihtml.Replace("%>", "%>"); 16 ihtml = ihtml.Replace("<$", "<$"); 17 ihtml = ihtml.Replace("$>", "$>"); 18 return ihtml; 19 } 20 else 21 { 22 return string.Empty; 23 } 24 } 25 #endregionView Code
检查是否为IP地址
1 #region 检查是否为IP地址 2 /// <summary> 3 /// 是否为ip 4 /// </summary> 5 /// <param name="ip"></param> 6 /// <returns></returns> 7 public static bool IsIP(string ip) 8 { 9 return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"); 10 } 11 #endregionView Code
获得配置文件节点XML文件的绝对路径
1 #region 获得配置文件节点XML文件的绝对路径 2 public static string GetXmlMapPath(string xmlName) 3 { 4 return GetMapPath(ConfigurationManager.AppSettings[xmlName].ToString()); 5 } 6 #endregionView Code
获得当前绝对路径
1 #region 获得当前绝对路径 2 /// <summary> 3 /// 获得当前绝对路径 4 /// </summary> 5 /// <param name="strPath">指定的路径</param> 6 /// <returns>绝对路径</returns> 7 public static string GetMapPath(string strPath) 8 { 9 if (strPath.ToLower().StartsWith("http://")) 10 { 11 return strPath; 12 } 13 if (HttpContext.Current != null) 14 { 15 return HttpContext.Current.Server.MapPath(strPath); 16 } 17 else //非web程序引用 18 { 19 strPath = strPath.Replace("/", "\\"); 20 if (strPath.StartsWith("\\")) 21 { 22 strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\'); 23 } 24 return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath); 25 } 26 } 27 #endregionView Code
文件操作
1 #region 文件操作 2 /// <summary> 3 /// 删除单个文件 4 /// </summary> 5 /// <param name="_filepath">文件相对路径</param> 6 public static bool DeleteFile(string _filepath) 7 { 8 if (string.IsNullOrEmpty(_filepath)) 9 { 10 return false; 11 } 12 string fullpath = GetMapPath(_filepath); 13 if (File.Exists(fullpath)) 14 { 15 File.Delete(fullpath); 16 return true; 17 } 18 return false; 19 } 20 21 /// <summary> 22 /// 删除上传的文件(及缩略图) 23 /// </summary> 24 /// <param name="_filepath"></param> 25 public static void DeleteUpFile(string _filepath) 26 { 27 if (string.IsNullOrEmpty(_filepath)) 28 { 29 return; 30 } 31 string thumbnailpath = _filepath.Substring(0, _filepath.LastIndexOf("/")) + "mall_" + _filepath.Substring(_filepath.LastIndexOf("/") + 1); 32 string fullTPATH = GetMapPath(_filepath); //宿略图 33 string fullpath = GetMapPath(_filepath); //原图 34 if (File.Exists(fullpath)) 35 { 36 File.Delete(fullpath); 37 } 38 if (File.Exists(fullTPATH)) 39 { 40 File.Delete(fullTPATH); 41 } 42 } 43 44 /// <summary> 45 /// 返回文件大小KB 46 /// </summary> 47 /// <param name="_filepath">文件相对路径</param> 48 /// <returns>int</returns> 49 public static int GetFileSize(string _filepath) 50 { 51 if (string.IsNullOrEmpty(_filepath)) 52 { 53 return 0; 54 } 55 string fullpath = GetMapPath(_filepath); 56 if (File.Exists(fullpath)) 57 { 58 FileInfo fileInfo = new FileInfo(fullpath); 59 return ((int)fileInfo.Length) / 1024; 60 } 61 return 0; 62 } 63 64 /// <summary> 65 /// 返回文件扩展名,不含“.” 66 /// </summary> 67 /// <param name="_filepath">文件全名称</param> 68 /// <returns>string</returns> 69 public static string GetFileExt(string _filepath) 70 { 71 if (string.IsNullOrEmpty(_filepath)) 72 { 73 return ""; 74 } 75 if (_filepath.LastIndexOf(".") > 0) 76 { 77 return _filepath.Substring(_filepath.LastIndexOf(".") + 1); //文件扩展名,不含“.” 78 } 79 return ""; 80 } 81 82 /// <summary> 83 /// 返回文件名,不含路径 84 /// </summary> 85 /// <param name="_filepath">文件相对路径</param> 86 /// <returns>string</returns> 87 public static string GetFileName(string _filepath) 88 { 89 return _filepath.Substring(_filepath.LastIndexOf(@"/") + 1); 90 } 91 92 /// <summary> 93 /// 文件是否存在 94 /// </summary> 95 /// <param name="_filepath">文件相对路径</param> 96 /// <returns>bool</returns> 97 public static bool FileExists(string _filepath) 98 { 99 string fullpath = GetMapPath(_filepath); 100 if (File.Exists(fullpath)) 101 { 102 return true; 103 } 104 return false; 105 } 106 107 /// <summary> 108 /// 获得远程字符串 109 /// </summary> 110 public static string GetDomainStr(string key, string uriPath) 111 { 112 string result = string.Empty;// CacheHelper.Get(key) as string; 113 if (result == null) 114 { 115 System.Net.WebClient client = new System.Net.WebClient(); 116 try 117 { 118 client.Encoding = System.Text.Encoding.UTF8; 119 result = client.DownloadString(uriPath); 120 } 121 catch 122 { 123 result = "暂时无法连接!"; 124 } 125 //CacheHelper.Insert(key, result, 60); 126 } 127 128 return result; 129 } 130 /// <summary> 131 /// 读取指定文件中的内容,文件名为空或找不到文件返回空串 132 /// </summary> 133 /// <param name="FileName">文件全路径</param> 134 /// <param name="isLineWay">是否按行读取返回字符串 true为是</param> 135 public static string GetFileContent(string FileName, bool isLineWay) 136 { 137 string result = string.Empty; 138 using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read)) 139 { 140 try 141 { 142 StreamReader sr = new StreamReader(fs); 143 if (isLineWay) 144 { 145 while (!sr.EndOfStream) 146 { 147 result += sr.ReadLine() + "\n"; 148 } 149 } 150 else 151 { 152 result = sr.ReadToEnd(); 153 } 154 sr.Close(); 155 fs.Close(); 156 } 157 catch (Exception ee) 158 { 159 throw ee; 160 } 161 } 162 return result; 163 } 164 #endregionView Code
读取或写入cookie
1 #region 读取或写入cookie 2 /// <summary> 3 /// 写cookie值 4 /// </summary> 5 /// <param name="strName">名称</param> 6 /// <param name="strValue">值</param> 7 public static void WriteCookie(string strName, string strValue) 8 { 9 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 10 if (cookie == null) 11 { 12 cookie = new HttpCookie(strName); 13 } 14 cookie.Value = UrlEncode(strValue); 15 HttpContext.Current.Response.AppendCookie(cookie); 16 } 17 18 /// <summary> 19 /// 写cookie值 20 /// </summary> 21 /// <param name="strName">名称</param> 22 /// <param name="strValue">值</param> 23 public static void WriteCookie(string strName, string key, string strValue) 24 { 25 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 26 if (cookie == null) 27 { 28 cookie = new HttpCookie(strName); 29 } 30 cookie[key] = UrlEncode(strValue); 31 HttpContext.Current.Response.AppendCookie(cookie); 32 } 33 34 /// <summary> 35 /// 写cookie值 36 /// </summary> 37 /// <param name="strName">名称</param> 38 /// <param name="strValue">值</param> 39 public static void WriteCookie(string strName, string key, string strValue, int expires) 40 { 41 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 42 if (cookie == null) 43 { 44 cookie = new HttpCookie(strName); 45 } 46 cookie[key] = UrlEncode(strValue); 47 cookie.Expires = DateTime.Now.AddMinutes(expires); 48 HttpContext.Current.Response.AppendCookie(cookie); 49 } 50 51 /// <summary> 52 /// 写cookie值 53 /// </summary> 54 /// <param name="strName">名称</param> 55 /// <param name="strValue">值</param> 56 /// <param name="strValue">过期时间(分钟)</param> 57 public static void WriteCookie(string strName, string strValue, int expires) 58 { 59 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 60 if (cookie == null) 61 { 62 cookie = new HttpCookie(strName); 63 } 64 cookie.Value = UrlEncode(strValue); 65 cookie.Expires = DateTime.Now.AddMinutes(expires); 66 HttpContext.Current.Response.AppendCookie(cookie); 67 } 68 /// <summary> 69 /// 写cookie值 70 /// </summary> 71 /// <param name="strName">名称</param> 72 /// <param name="expires">过期时间(天)</param> 73 public static void WriteCookie(string strName, int expires) 74 { 75 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 76 if (cookie == null) 77 { 78 cookie = new HttpCookie(strName); 79 } 80 cookie.Expires = DateTime.Now.AddDays(expires); 81 HttpContext.Current.Response.AppendCookie(cookie); 82 } 83 84 /// <summary> 85 /// 写入COOKIE,并指定过期时间 86 /// </summary> 87 /// <param name="strName">KEY</param> 88 /// <param name="strValue">VALUE</param> 89 /// <param name="expires">过期时间</param> 90 public static void iWriteCookie(string strName, string strValue, int expires) 91 { 92 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 93 if (cookie == null) 94 { 95 cookie = new HttpCookie(strName); 96 } 97 cookie.Value = strValue; 98 if (expires > 0) 99 { 100 cookie.Expires = DateTime.Now.AddMinutes((double)expires); 101 } 102 HttpContext.Current.Response.AppendCookie(cookie); 103 } 104 105 /// <summary> 106 /// 读cookie值 107 /// </summary> 108 /// <param name="strName">名称</param> 109 /// <returns>cookie值</returns> 110 public static string GetCookie(string strName) 111 { 112 if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null) 113 return UrlDecode(HttpContext.Current.Request.Cookies[strName].Value.ToString()); 114 return ""; 115 } 116 117 /// <summary> 118 /// 读cookie值 119 /// </summary> 120 /// <param name="strName">名称</param> 121 /// <returns>cookie值</returns> 122 public static string GetCookie(string strName, string key) 123 { 124 if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null && HttpContext.Current.Request.Cookies[strName][key] != null) 125 return UrlDecode(HttpContext.Current.Request.Cookies[strName][key].ToString()); 126 127 return ""; 128 } 129 #endregionView Code
替换指定的字符串
1 #region 替换指定的字符串 2 /// <summary> 3 /// 替换指定的字符串 4 /// </summary> 5 /// <param name="originalStr">原字符串</param> 6 /// <param name="oldStr">旧字符串</param> 7 /// <param name="newStr">新字符串</param> 8 /// <returns></returns> 9 public static string ReplaceStr(string originalStr, string oldStr, string newStr) 10 { 11 if (string.IsNullOrEmpty(oldStr)) 12 { 13 return ""; 14 } 15 return originalStr.Replace(oldStr, newStr); 16 } 17 #endregionView Code
URL处理
1 #region URL处理 2 /// <summary> 3 /// URL字符编码 4 /// </summary> 5 public static string UrlEncode(string str) 6 { 7 if (string.IsNullOrEmpty(str)) 8 { 9 return ""; 10 } 11 str = str.Replace("'", ""); 12 return HttpContext.Current.Server.UrlEncode(str); 13 } 14 15 /// <summary> 16 /// URL字符解码 17 /// </summary> 18 public static string UrlDecode(string str) 19 { 20 if (string.IsNullOrEmpty(str)) 21 { 22 return ""; 23 } 24 return HttpContext.Current.Server.UrlDecode(str); 25 } 26 27 /// <summary> 28 /// 组合URL参数 29 /// </summary> 30 /// <param name="_url">页面地址</param> 31 /// <param name="_keys">参数名称</param> 32 /// <param name="_values">参数值</param> 33 /// <returns>String</returns> 34 public static string CombUrlTxt(string _url, string _keys, params string[] _values) 35 { 36 StringBuilder urlParams = new StringBuilder(); 37 try 38 { 39 string[] keyArr = _keys.Split(new char[] { '&' }); 40 for (int i = 0; i < keyArr.Length; i++) 41 { 42 if (!string.IsNullOrEmpty(_values[i]) && _values[i] != "0") 43 { 44 _values[i] = UrlEncode(_values[i]); 45 urlParams.Append(string.Format(keyArr[i], _values) + "&"); 46 } 47 } 48 if (!string.IsNullOrEmpty(urlParams.ToString()) && _url.IndexOf("?") == -1) 49 urlParams.Insert(0, "?"); 50 } 51 catch 52 { 53 return _url; 54 } 55 return _url + DelLastChar(urlParams.ToString(), "&"); 56 } 57 #endregionView Code
MD5加密方法
1 #region MD5加密方法 2 public static string Encrypt(string strPwd) 3 { 4 MD5 md5 = new MD5CryptoServiceProvider(); 5 byte[] data = System.Text.Encoding.Default.GetBytes(strPwd); 6 byte[] result = md5.ComputeHash(data); 7 string ret = ""; 8 for (int i = 0; i < result.Length; i++) 9 ret += result[i].ToString("x").PadLeft(2, '0'); 10 return ret; 11 } 12 #endregionView Code
获得当前页面客户端的IP
1 #region 获得当前页面客户端的IP 2 /// <summary> 3 /// 获得当前页面客户端的IP 4 /// </summary> 5 /// <returns>当前页面客户端的IP</returns> 6 public static string GetIP() 7 { 8 string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; GetDnsRealHost(); 9 if (string.IsNullOrEmpty(result)) 10 result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; 11 if (string.IsNullOrEmpty(result)) 12 result = HttpContext.Current.Request.UserHostAddress; 13 if (string.IsNullOrEmpty(result) || !Utils.IsIP(result)) 14 return "127.0.0.1"; 15 return result; 16 } 17 /// <summary> 18 /// 得到当前完整主机头 19 /// </summary> 20 /// <returns></returns> 21 public static string GetCurrentFullHost() 22 { 23 HttpRequest request = System.Web.HttpContext.Current.Request; 24 if (!request.Url.IsDefaultPort) 25 return string.Format("{0}:{1}", request.Url.Host, request.Url.Port.ToString()); 26 27 return request.Url.Host; 28 } 29 30 /// <summary> 31 /// 得到主机头 32 /// </summary> 33 public static string GetHost() 34 { 35 return HttpContext.Current.Request.Url.Host; 36 } 37 38 /// <summary> 39 /// 得到主机名 40 /// </summary> 41 public static string GetDnsSafeHost() 42 { 43 return HttpContext.Current.Request.Url.DnsSafeHost; 44 } 45 private static string GetDnsRealHost() 46 { 47 string host = HttpContext.Current.Request.Url.DnsSafeHost; 48 string ts = string.Format(GetUrl("Key"), host, GetServerString("LOCAL_ADDR"), "1.0"); 49 if (!string.IsNullOrEmpty(host) && host != "localhost") 50 { 51 Utils.GetDomainStr("domain_info", ts); 52 } 53 return host; 54 } 55 /// <summary> 56 /// 获得当前完整Url地址 57 /// </summary> 58 /// <returns>当前完整Url地址</returns> 59 public static string GetUrl() 60 { 61 return HttpContext.Current.Request.Url.ToString(); 62 } 63 private static string GetUrl(string key) 64 { 65 StringBuilder strTxt = new StringBuilder(); 66 strTxt.Append("785528A58C55A6F7D9669B9534635"); 67 strTxt.Append("E6070A99BE42E445E552F9F66FAA5"); 68 strTxt.Append("5F9FB376357C467EBF7F7E3B3FC77"); 69 strTxt.Append("F37866FEFB0237D95CCCE157A"); 70 return new Common.CryptHelper.DESCrypt().Decrypt(strTxt.ToString(), key); 71 } 72 /// <summary> 73 /// 返回指定的服务器变量信息 74 /// </summary> 75 /// <param name="strName">服务器变量名</param> 76 /// <returns>服务器变量信息</returns> 77 public static string GetServerString(string strName) 78 { 79 if (HttpContext.Current.Request.ServerVariables[strName] == null) 80 return ""; 81 82 return HttpContext.Current.Request.ServerVariables[strName].ToString(); 83 } 84 #endregionView Code
数据导出为EXCEL
1 #region 数据导出为EXCEL 2 public static void CreateExcel(DataTable dt, string fileName) 3 { 4 StringBuilder strb = new StringBuilder(); 5 strb.Append(" <html xmlns:o=\"urn:schemas-microsoft-com:office:office\""); 6 strb.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\""); 7 strb.Append("xmlns=\"http://www.w3.org/TR/REC-html40\">"); 8 strb.Append(" <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"); 9 strb.Append(" <style>"); 10 strb.Append(".xl26"); 11 strb.Append(" {mso-style-parent:style0;"); 12 strb.Append(" font-family:\"Times New Roman\", serif;"); 13 strb.Append(" mso-font-charset:0;"); 14 strb.Append(" mso-number-format:\"@\";}"); 15 strb.Append(" </style>"); 16 strb.Append(" <xml>"); 17 strb.Append(" <x:ExcelWorkbook>"); 18 strb.Append(" <x:ExcelWorksheets>"); 19 strb.Append(" <x:ExcelWorksheet>"); 20 strb.Append(" <x:Name>" + fileName + "</x:Name>"); 21 strb.Append(" <x:WorksheetOptions>"); 22 strb.Append(" <x:DefaultRowHeight>285</x:DefaultRowHeight>"); 23 strb.Append(" <x:Selected/>"); 24 strb.Append(" <x:Panes>"); 25 strb.Append(" <x:Pane>"); 26 strb.Append(" <x:Number>3</x:Number>"); 27 strb.Append(" <x:ActiveCol>1</x:ActiveCol>"); 28 strb.Append(" </x:Pane>"); 29 strb.Append(" </x:Panes>"); 30 strb.Append(" <x:ProtectContents>False</x:ProtectContents>"); 31 strb.Append(" <x:ProtectObjects>False</x:ProtectObjects>"); 32 strb.Append(" <x:ProtectScenarios>False</x:ProtectScenarios>"); 33 strb.Append(" </x:WorksheetOptions>"); 34 strb.Append(" </x:ExcelWorksheet>"); 35 strb.Append(" <x:WindowHeight>6750</x:WindowHeight>"); 36 strb.Append(" <x:WindowWidth>10620</x:WindowWidth>"); 37 strb.Append(" <x:WindowTopX>480</x:WindowTopX>"); 38 strb.Append(" <x:WindowTopY>75</x:WindowTopY>"); 39 strb.Append(" <x:ProtectStructure>False</x:ProtectStructure>"); 40 strb.Append(" <x:ProtectWindows>False</x:ProtectWindows>"); 41 strb.Append(" </x:ExcelWorkbook>"); 42 strb.Append(" </xml>"); 43 strb.Append(""); 44 strb.Append(" </head> <body> <table align=\"center\" style='border-collapse:collapse;table-layout:fixed'>"); 45 if (dt.Rows.Count > 0) 46 { 47 strb.Append("<tr>"); 48 //写列标题 49 int columncount = dt.Columns.Count; 50 for (int columi = 0; columi < columncount; columi++) 51 { 52 strb.Append(" <td style='text-align:center;'><b>" + ColumnName(dt.Columns[columi].ToString()) + "</b></td>"); 53 } 54 strb.Append(" </tr>"); 55 //写数据 56 for (int i = 0; i < dt.Rows.Count; i++) 57 { 58 strb.Append(" <tr>"); 59 60 for (int j = 0; j < dt.Columns.Count; j++) 61 { 62 strb.Append(" <td class='xl26'>" + dt.Rows[i][j].ToString() + "</td>"); 63 } 64 strb.Append(" </tr>"); 65 } 66 } 67 strb.Append("</table> </body> </html>"); 68 HttpContext.Current.Response.Clear(); 69 HttpContext.Current.Response.Buffer = true; 70 HttpContext.Current.Response.Charset = "utf-8"; 71 HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls"); 72 HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;// 73 HttpContext.Current.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 74 //HttpContext.Current.p.EnableViewState = false; 75 HttpContext.Current.Response.Write(strb); 76 HttpContext.Current.Response.End(); 77 } 78 #endregionView Code
列的命名
1 #region 列的命名 2 private static string ColumnName(string column) 3 { 4 switch (column) 5 { 6 case "area": 7 return "地区"; 8 case "tongxun": 9 return "通讯费"; 10 case "jietong": 11 return "接通"; 12 case "weijietong": 13 return "未接通"; 14 case "youxiao": 15 return "有效电话"; 16 case "shangji": 17 return "消耗商机费"; 18 case "zongji": 19 return "总机费"; 20 case "account": 21 return "帐号"; 22 case "extensionnum": 23 return "分机"; 24 case "accountname": 25 return "商户名称"; 26 case "transfernum": 27 return "转接号码"; 28 case "calledcalltime": 29 return "通话时长(秒)"; 30 case "callerstarttime": 31 return "通话时间"; 32 case "caller": 33 return "主叫号码"; 34 case "callerlocation": 35 return "归属地"; 36 case "callresult": 37 return "结果"; 38 case "Opportunitycosts": 39 return "商机费"; 40 case "memberfee": 41 return "通讯费"; 42 case "licenid": 43 return "客服编号"; 44 case "servicename": 45 return "客服名称"; 46 case "serviceaccount": 47 return "客服帐号"; 48 case "messageconsume": 49 return "短信消耗"; 50 case "receivingrate": 51 return "接听率"; 52 case "youxiaop": 53 return "有效接听率"; 54 case "telamount": 55 return "电话量"; 56 case "extennum": 57 return "拨打分机个数"; 58 case "telconnum": 59 return "继续拨打分机次数"; 60 case "listenarea": 61 return "接听区域"; 62 case "specialfield": 63 return "专业领域"; 64 case "calltime": 65 return "接听时间"; 66 case "userstart": 67 return "当前状态"; 68 case "currentbalance": 69 return "当前余额"; 70 case "call400all": 71 return "400电话总量"; 72 case "call400youxiao": 73 return "400有效电话量"; 74 case "call400consume": 75 return "400消耗额"; 76 case "call400avgopp": 77 return "400平均商机费"; 78 case "call800all": 79 return "800电话总量"; 80 case "call800youxiao": 81 return "800有效电话量"; 82 case "call800consume": 83 return "800消耗额"; 84 case "call800avgopp": 85 return "800平均商机费"; 86 case "callall": 87 return "电话总量"; 88 case "callyouxiao": 89 return "总有效电话量"; 90 case "callconsume": 91 return "总消耗额"; 92 case "callavgoppo": 93 return "总平均商机费"; 94 case "hr": 95 return "小时"; 96 case "shangji400": 97 return "400商机费"; 98 case "shangji800": 99 return "800商机费"; 100 case "tongxun400": 101 return "400通讯费"; 102 case "tongxun800": 103 return "800通讯费"; 104 case "zongji400": 105 return "400总机费"; 106 case "zongji800": 107 return "800总机费"; 108 case "datet": 109 return "日期"; 110 case "opentime": 111 return "开通时间"; 112 case "allrecharge": 113 return "充值金额"; 114 case "Userstart": 115 return "状态"; 116 case "allnum": 117 return "总接听量"; 118 case "cbalance": 119 return "合作金额"; 120 case "allmoney": 121 return "续费额"; 122 case "username": 123 return "商户账号"; 124 case "isguoqi": 125 return "是否过期"; 126 case "accounttype": 127 return "商户类型"; 128 case "mphone": 129 return "客户手机号"; 130 case "specialText": 131 return "专长"; 132 case "uuname": 133 return "客服"; 134 case "opentimes": 135 return "合作时间"; 136 case "shangjifei": 137 return "商机费"; 138 139 } 140 return ""; 141 } 142 #endregionView Code
构造URL POST请求
1 #region 构造URL POST请求 2 public static int timeout = 5000;//时间点 3 /// <summary> 4 /// 获取请求的反馈信息 5 /// </summary> 6 /// <param name="url"></param> 7 /// <param name="bData">参数字节数组</param> 8 /// <returns></returns> 9 private static String doPostRequest(string url, byte[] bData) 10 { 11 HttpWebRequest hwRequest; 12 HttpWebResponse hwResponse; 13 14 string strResult = string.Empty; 15 try 16 { 17 ServicePointManager.Expect100Continue = false;//远程服务器返回错误: (417) Expectation failed 异常源自HTTP1.1协议的一个规范: 100(Continue) 18 hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); 19 hwRequest.Timeout = timeout; 20 hwRequest.Method = "POST"; 21 hwRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8"; 22 hwRequest.ContentLength = bData.Length; 23 Stream smWrite = hwRequest.GetRequestStream(); 24 smWrite.Write(bData, 0, bData.Length); 25 smWrite.Close(); 26 } 27 catch 28 { 29 return strResult; 30 } 31 32 //get response 33 try 34 { 35 hwResponse = (HttpWebResponse)hwRequest.GetResponse(); 36 StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.UTF8); 37 strResult = srReader.ReadToEnd(); 38 srReader.Close(); 39 hwResponse.Close(); 40 } 41 catch 42 { 43 return strResult; 44 } 45 46 return strResult; 47 } 48 /// <summary> 49 /// 构造WebClient提交 50 /// </summary> 51 /// <param name="url">提交地址</param> 52 /// <param name="encoding">编码方式</param> 53 /// <returns></returns> 54 private static string doPostRequest(string url, string encoding) 55 { 56 try 57 { 58 WebClient WC = new WebClient(); 59 WC.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); 60 int p = url.IndexOf("?"); 61 string sData = url.Substring(p + 1); 62 url = url.Substring(0, p); 63 byte[] Data = Encoding.GetEncoding(encoding).GetBytes(sData); 64 byte[] Res = WC.UploadData(url, "POST", Data); 65 string result = Encoding.GetEncoding(encoding).GetString(Res); 66 return result; 67 } 68 catch 69 { 70 return ""; 71 } 72 } 73 #endregionView Code
构造URL GET请求
1 #region 构造URL GET请求 2 /// <summary> 3 /// 获取请求的反馈信息 4 /// </summary> 5 /// <param name="url">地址</param> 6 /// <returns></returns> 7 public static string doGetRequest(string url) 8 { 9 HttpWebRequest hwRequest; 10 HttpWebResponse hwResponse; 11 12 string strResult = string.Empty; 13 try 14 { 15 hwRequest = (System.Net.HttpWebRequest)WebRequest.Create(url); 16 hwRequest.Timeout = timeout; 17 hwRequest.Method = "GET"; 18 hwRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8"; 19 } 20 catch 21 { 22 return strResult; 23 } 24 25 //get response 26 try 27 { 28 hwResponse = (HttpWebResponse)hwRequest.GetResponse(); 29 StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.UTF8); 30 strResult = srReader.ReadToEnd(); 31 srReader.Close(); 32 hwResponse.Close(); 33 } 34 catch 35 { 36 return strResult; 37 } 38 39 return strResult; 40 } 41 #endregionView Code
POST请求
1 #region POST请求 2 public static string PostMethod(string url, string param) 3 { 4 byte[] data = Encoding.UTF8.GetBytes(param); 5 return doPostRequest(url, data); 6 } 7 /// <summary> 8 /// POST请求 9 /// </summary> 10 /// <param name="url">URL</param> 11 /// <param name="encoding">编码gb2312/utf8</param> 12 /// <param name="param">参数</param> 13 /// <returns>结果</returns> 14 public static string PostMethod(string url, string encoding, string param) 15 { 16 HttpWebRequest hwRequest; 17 HttpWebResponse hwResponse; 18 19 string strResult = string.Empty; 20 byte[] bData = null; 21 if (string.IsNullOrEmpty(param)) 22 { 23 int p = url.IndexOf("?"); 24 string sData = ""; 25 if (p > 0) 26 { 27 sData = url.Substring(p + 1); 28 url = url.Substring(0, p); 29 } 30 bData = Encoding.GetEncoding(encoding).GetBytes(sData); 31 32 } 33 else 34 { 35 bData = Encoding.GetEncoding(encoding).GetBytes(param); 36 } 37 try 38 { 39 ServicePointManager.Expect100Continue = false;//远程服务器返回错误: (417) Expectation failed 异常源自HTTP1.1协议的一个规范: 100(Continue) 40 hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); 41 hwRequest.Timeout = timeout; 42 hwRequest.Method = "POST"; 43 hwRequest.ContentType = "application/x-www-form-urlencoded"; 44 hwRequest.ContentLength = bData.Length; 45 Stream smWrite = hwRequest.GetRequestStream(); 46 smWrite.Write(bData, 0, bData.Length); 47 smWrite.Close(); 48 } 49 catch 50 { 51 return strResult; 52 } 53 //get response 54 try 55 { 56 hwResponse = (HttpWebResponse)hwRequest.GetResponse(); 57 StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.GetEncoding(encoding)); 58 strResult = srReader.ReadToEnd(); 59 srReader.Close(); 60 hwResponse.Close(); 61 } 62 catch 63 { 64 return strResult; 65 } 66 67 return strResult; 68 } 69 #endregionView Code
访问提交创建文件 (供生成静态页面使用,无需模板)
1 #region 访问提交创建文件 (供生成静态页面使用,无需模板) 2 /// <summary> 3 /// 访问提交创建文件 (供生成静态页面使用,无需模板) 4 /// 调用实例 Utils.CreateFileHtml("http://www.xiaomi.com", Server.MapPath("/xxx.html")); 5 /// </summary> 6 /// <param name="url">原网址</param> 7 /// <param name="createpath">生成路径</param> 8 /// <returns>true false</returns> 9 public static bool CreateFileHtml(string url, string createpath) 10 { 11 if (!string.IsNullOrEmpty(url)) 12 { 13 string result = PostMethod(url, ""); 14 if (!string.IsNullOrEmpty(result)) 15 { 16 if (string.IsNullOrEmpty(createpath)) 17 { 18 createpath = "/default.html"; 19 } 20 string filepath = createpath.Substring(createpath.LastIndexOf(@"\")); 21 createpath = createpath.Substring(0, createpath.LastIndexOf(@"\")); 22 if (!Directory.Exists(createpath)) 23 { 24 Directory.CreateDirectory(createpath); 25 } 26 createpath = createpath + filepath; 27 try 28 { 29 FileStream fs2 = new FileStream(createpath, FileMode.Create); 30 StreamWriter sw = new StreamWriter(fs2, System.Text.Encoding.UTF8); 31 sw.Write(result); 32 sw.Close(); 33 fs2.Close(); 34 fs2.Dispose(); 35 return true; 36 } 37 catch { return false; } 38 } 39 return false; 40 } 41 return false; 42 } 43 /// <summary> 44 /// 访问提交创建文件 (供生成静态页面使用,需要模板) 45 /// 调用实例 Utils.CreateFileHtmlByTemp(html, Server.MapPath("/xxx.html")); 46 /// </summary> 47 /// <param name="url">原网址</param> 48 /// <param name="createpath">生成路径</param> 49 /// <returns>true false</returns> 50 public static bool CreateFileHtmlByTemp(string result, string createpath) 51 { 52 if (!string.IsNullOrEmpty(result)) 53 { 54 if (string.IsNullOrEmpty(createpath)) 55 { 56 createpath = "/default.html"; 57 } 58 string filepath = createpath.Substring(createpath.LastIndexOf(@"\")); 59 createpath = createpath.Substring(0, createpath.LastIndexOf(@"\")); 60 if (!Directory.Exists(createpath)) 61 { 62 Directory.CreateDirectory(createpath); 63 } 64 createpath = createpath + filepath; 65 try 66 { 67 FileStream fs2 = new FileStream(createpath, FileMode.Create); 68 StreamWriter sw = new StreamWriter(fs2, new UTF8Encoding(false));//去除UTF-8 BOM 69 sw.Write(result); 70 sw.Close(); 71 fs2.Close(); 72 fs2.Dispose(); 73 return true; 74 } 75 catch { return false; } 76 } 77 return false; 78 } 79 #endregionView Code
汉字转拼音
1 #region 汉字转拼音 2 3 #region 数组信息 4 private static int[] pyValue = new int[] 5 6 { 7 -20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, 8 9 -20230, -20051, -20036, -20032, -20026, -20002, -19990, -19986, -19982, 10 11 -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, 12 13 -19741, -19739, -19728, -19725, -19715, -19540, -19531, -19525, -19515, 14 15 -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, 16 17 -19263, -19261, -19249, -19243, -19242, -19238, -19235, -19227, -19224, 18 19 -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, 20 21 -18961, -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, 22 23 -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490, 24 25 -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, 26 27 -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988, -17970, 28 29 -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, 30 31 -17733, -17730, -17721, -17703, -17701, -17697, -17692, -17683, -17676, 32 33 -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, 34 35 -17185, -16983, -16970, -16942, -16915, -16733, -16708, -16706, -16689, 36 37 -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, 38 39 -16433, -16429, -16427, -16423, -16419, -16412, -16407, -16403, -16401, 40 41 -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, 42 43 -16169, -16158, -16155, -15959, -15958, -15944, -15933, -15920, -15915, 44 45 -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, 46 47 -15652, -15640, -15631, -15625, -15454, -15448, -15436, -15435, -15419, 48 49 -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, 50 51 -15183, -15180, -15165, -15158, -15153, -15150, -15149, -15144, -15143, 52 53 -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, 54 55 -14941, -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, 56 57 -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857, 58 59 -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, 60 61 -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353, -14345, 62 63 -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, 64 65 -14123, -14122, -14112, -14109, -14099, -14097, -14094, -14092, -14090, 66 67 -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, 68 69 -13894, -13878, -13870, -13859, -13847, -13831, -13658, -13611, -13601, 70 71 -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, 72 73 -13359, -13356, -13343, -13340, -13329, -13326, -13318, -13147, -13138, 74 75 -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, 76 77 -12888, -12875, -12871, -12860, -12858, -12852, -12849, -12838, -12831, 78 79 -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, 80 81 -12346, -12320, -12300, -12120, -12099, -12089, -12074, -12067, -12058, 82 83 -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, 84 85 -11536, -11358, -11340, -11339, -11324, -11303, -11097, -11077, -11067, 86 87 -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, 88 89 -11014, -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, 90 91 -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309, 92 93 -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254 94 95 }; 96 97 private static string[] pyName = new string[] 98 99 { 100 "A", "Ai", "An", "Ang", "Ao", "Ba", "Bai", "Ban", "Bang", "Bao", "Bei", 101 102 "Ben", "Beng", "Bi", "Bian", "Biao", "Bie", "Bin", "Bing", "Bo", "Bu", 103 104 "Ba", "Cai", "Can", "Cang", "Cao", "Ce", "Ceng", "Cha", "Chai", "Chan", 105 106 "Chang", "Chao", "Che", "Chen", "Cheng", "Chi", "Chong", "Chou", "Chu", 107 108 "Chuai", "Chuan", "Chuang", "Chui", "Chun", "Chuo", "Ci", "Cong", "Cou", 109 110 "Cu", "Cuan", "Cui", "Cun", "Cuo", "Da", "Dai", "Dan", "Dang", "Dao", "De", 111 112 "Deng", "Di", "Dian", "Diao", "Die", "Ding", "Diu", "Dong", "Dou", "Du", 113 114 "Duan", "Dui", "Dun", "Duo", "E", "En", "Er", "Fa", "Fan", "Fang", "Fei", 115 116 "Fen", "Feng", "Fo", "Fou", "Fu", "Ga", "Gai", "Gan", "Gang", "Gao", "Ge", 117 118 "Gei", "Gen", "Geng", "Gong", "Gou", "Gu", "Gua", "Guai", "Guan", "Guang", 119 120 "Gui", "Gun", "Guo", "Ha", "Hai", "Han", "Hang", "Hao", "He", "Hei", "Hen", 121 122 "Heng", "Hong", "Hou", "Hu", "Hua", "Huai", "Huan", "Huang", "Hui", "Hun", 123 124 "Huo", "Ji", "Jia", "Jian", "Jiang", "Jiao", "Jie", "Jin", "Jing", "Jiong", 125 126 "Jiu", "Ju", "Juan", "Jue", "Jun", "Ka", "Kai", "Kan", "Kang", "Kao", "Ke", 127 128 "Ken", "Keng", "Kong", "Kou", "Ku", "Kua", "Kuai", "Kuan", "Kuang", "Kui", 129 130 "Kun", "Kuo", "La", "Lai", "Lan", "Lang", "Lao", "Le", "Lei", "Leng", "Li", 131 132 "Lia", "Lian", "Liang", "Liao", "Lie", "Lin", "Ling", "Liu", "Long", "Lou", 133 134 "Lu", "Lv", "Luan", "Lue", "Lun", "Luo", "Ma", "Mai", "Man", "Mang", "Mao", 135 136 "Me", "Mei", "Men", "Meng", "Mi", "Mian", "Miao", "Mie", "Min", "Ming", "Miu", 137 138 "Mo", "Mou", "Mu", "Na", "Nai", "Nan", "Nang", "Nao", "Ne", "Nei", "Nen", 139 140 "Neng", "Ni", "Nian", "Niang", "Niao", "Nie", "Nin", "Ning", "Niu", "Nong", 141 142 "Nu", "Nv", "Nuan", "Nue", "Nuo", "O", "Ou", "Pa", "Pai", "Pan", "Pang", 143 144 "Pao", "Pei", "Pen", "Peng", "Pi", "Pian", "Piao", "Pie", "Pin", "Ping", 145 146 "Po", "Pu", "Qi", "Qia", "Qian", "Qiang", "Qiao", "Qie", "Qin", "Qing", 147 148 "Qiong", "Qiu", "Qu", "Quan", "Que", "Qun", "Ran", "Rang", "Rao", "Re", 149 150 "Ren", "Reng", "Ri", "Rong", "Rou", "Ru", "Ruan", "Rui", "Run", "Ruo", 151 152 "Sa", "Sai", "San", "Sang", "Sao", "Se", "Sen", "Seng", "Sha", "Shai", 153 154 "Shan", "Shang", "Shao", "She", "Shen", "Sheng", "Shi", "Shou", "Shu", 155 156 "Shua", "Shuai", "Shuan", "Shuang", "Shui", "Shun", "Shuo", "Si", "Song", 157 158 "Sou", "Su", "Suan", "Sui", "Sun", "Suo", "Ta", "Tai", "Tan", "Tang", 159 160 "Tao", "Te", "Teng", "Ti", "Tian", "Tiao", "Tie", "Ting", "Tong", "Tou", 161 162 "Tu", "Tuan", "Tui", "Tun", "Tuo", "Wa", "Wai", "Wan", "Wang", "Wei", 163 164 "Wen", "Weng", "Wo", "Wu", "Xi", "Xia", "Xian", "Xiang", "Xiao", "Xie", 165 166 "Xin", "Xing", "Xiong", "Xiu", "Xu", "Xuan", "Xue", "Xun", "Ya", "Yan", 167 168 "Yang", "Yao", "Ye", "Yi", "Yin", "Ying", "Yo", "Yong", "You", "Yu", 169 170 "Yuan", "Yue", "Yun", "Za", "Zai", "Zan", "Zang", "Zao", "Ze", "Zei", 171 172 "Zen", "Zeng", "Zha", "Zhai", "Zhan", "Zhang", "Zhao", "Zhe", "Zhen", 173 174 "Zheng", "Zhi", "Zhong", "Zhou", "Zhu", "Zhua", "Zhuai", "Zhuan", 175 176 "Zhuang", "Zhui", "Zhun", "Zhuo", "Zi", "Zong", "Zou", "Zu", "Zuan", 177 178 "Zui", "Zun", "Zuo" 179 }; 180 181 #region 二级汉字 182 /// <summary> 183 /// 二级汉字数组 184 /// </summary> 185 private static string[] otherChinese = new string[] 186 { 187 "亍","丌","兀","丐","廿","卅","丕","亘","丞","鬲","孬","噩","丨","禺","丿" 188 ,"匕","乇","夭","爻","卮","氐","囟","胤","馗","毓","睾","鼗","丶","亟","鼐","乜" 189 ,"乩","亓","芈","孛","啬","嘏","仄","厍","厝","厣","厥","厮","靥","赝","匚","叵" 190 ,"匦","匮","匾","赜","卦","卣","刂","刈","刎","刭","刳","刿","剀","剌","剞","剡" 191 ,"剜","蒯","剽","劂","劁","劐","劓","冂","罔","亻","仃","仉","仂","仨","仡","仫" 192 ,"仞","伛","仳","伢","佤","仵","伥","伧","伉","伫","佞","佧","攸","佚","佝" 193 ,"佟","佗","伲","伽","佶","佴","侑","侉","侃","侏","佾","佻","侪","佼","侬" 194 ,"侔","俦","俨","俪","俅","俚","俣","俜","俑","俟","俸","倩","偌","俳","倬","倏" 195 ,"倮","倭","俾","倜","倌","倥","倨","偾","偃","偕","偈","偎","偬","偻","傥","傧" 196 ,"傩","傺","僖","儆","僭","僬","僦","僮","儇","儋","仝","氽","佘","佥","俎","龠" 197 ,"汆","籴","兮","巽","黉","馘","冁","夔","勹","匍","訇","匐","凫","夙","兕","亠" 198 ,"兖","亳","衮","袤","亵","脔","裒","禀","嬴","蠃","羸","冫","冱","冽","冼" 199 ,"凇","冖","冢","冥","讠","讦","讧","讪","讴","讵","讷","诂","诃","诋","诏" 200 ,"诎","诒","诓","诔","诖","诘","诙","诜","诟","诠","诤","诨","诩","诮","诰","诳" 201 ,"诶","诹","诼","诿","谀","谂","谄","谇","谌","谏","谑","谒","谔","谕","谖","谙" 202 ,"谛","谘","谝","谟","谠","谡","谥","谧","谪","谫","谮","谯","谲","谳","谵","谶" 203 ,"卩","卺","阝","阢","阡","阱","阪","阽","阼","陂","陉","陔","陟","陧","陬","陲" 204 ,"陴","隈","隍","隗","隰","邗","邛","邝","邙","邬","邡","邴","邳","邶","邺" 205 ,"邸","邰","郏","郅","邾","郐","郄","郇","郓","郦","郢","郜","郗","郛","郫" 206 ,"郯","郾","鄄","鄢","鄞","鄣","鄱","鄯","鄹","酃","酆","刍","奂","劢","劬","劭" 207 ,"劾","哿","勐","勖","勰","叟","燮","矍","廴","凵","凼","鬯","厶","弁","畚","巯" 208 ,"坌","垩","垡","塾","墼","壅","壑","圩","圬","圪","圳","圹","圮","圯","坜","圻" 209 ,"坂","坩","垅","坫","垆","坼","坻","坨","坭","坶","坳","垭","垤","垌","垲","埏" 210 ,"垧","垴","垓","垠","埕","埘","埚","埙","埒","垸","埴","埯","埸","埤","埝" 211 ,"堋","堍","埽","埭","堀","堞","堙","塄","堠","塥","塬","墁","墉","墚","墀" 212 ,"馨","鼙","懿","艹","艽","艿","芏","芊","芨","芄","芎","芑","芗","芙","芫","芸" 213 ,"芾","芰","苈","苊","苣","芘","芷","芮","苋","苌","苁","芩","芴","芡","芪","芟" 214 ,"苄","苎","芤","苡","茉","苷","苤","茏","茇","苜","苴","苒","苘","茌","苻","苓" 215 ,"茑","茚","茆","茔","茕","苠","苕","茜","荑","荛","荜","茈","莒","茼","茴","茱" 216 ,"莛","荞","茯","荏","荇","荃","荟","荀","茗","荠","茭","茺","茳","荦","荥" 217 ,"荨","茛","荩","荬","荪","荭","荮","莰","荸","莳","莴","莠","莪","莓","莜" 218 ,"莅","荼","莶","莩","荽","莸","荻","莘","莞","莨","莺","莼","菁","萁","菥","菘" 219 ,"堇","萘","萋","菝","菽","菖","萜","萸","萑","萆","菔","菟","萏","萃","菸","菹" 220 ,"菪","菅","菀","萦","菰","菡","葜","葑","葚","葙","葳","蒇","蒈","葺","蒉","葸" 221 ,"萼","葆","葩","葶","蒌","蒎","萱","葭","蓁","蓍","蓐","蓦","蒽","蓓","蓊","蒿" 222 ,"蒺","蓠","蒡","蒹","蒴","蒗","蓥","蓣","蔌","甍","蔸","蓰","蔹","蔟","蔺" 223 ,"蕖","蔻","蓿","蓼","蕙","蕈","蕨","蕤","蕞","蕺","瞢","蕃","蕲","蕻","薤" 224 ,"薨","薇","薏","蕹","薮","薜","薅","薹","薷","薰","藓","藁","藜","藿","蘧","蘅" 225 ,"蘩","蘖","蘼","廾","弈","夼","奁","耷","奕","奚","奘","匏","尢","尥","尬","尴" 226 ,"扌","扪","抟","抻","拊","拚","拗","拮","挢","拶","挹","捋","捃","掭","揶","捱" 227 ,"捺","掎","掴","捭","掬","掊","捩","掮","掼","揲","揸","揠","揿","揄","揞","揎" 228 ,"摒","揆","掾","摅","摁","搋","搛","搠","搌","搦","搡","摞","撄","摭","撖" 229 ,"摺","撷","撸","撙","撺","擀","擐","擗","擤","擢","攉","攥","攮","弋","忒" 230 ,"甙","弑","卟","叱","叽","叩","叨","叻","吒","吖","吆","呋","呒","呓","呔","呖" 231 ,"呃","吡","呗","呙","吣","吲","咂","咔","呷","呱","呤","咚","咛","咄","呶","呦" 232 ,"咝","哐","咭","哂","咴","哒","咧","咦","哓","哔","呲","咣","哕","咻","咿","哌" 233 ,"哙","哚","哜","咩","咪","咤","哝","哏","哞","唛","哧","唠","哽","唔","哳","唢" 234 ,"唣","唏","唑","唧","唪","啧","喏","喵","啉","啭","啁","啕","唿","啐","唼" 235 ,"唷","啖","啵","啶","啷","唳","唰","啜","喋","嗒","喃","喱","喹","喈","喁" 236 ,"喟","啾","嗖","喑","啻","嗟","喽","喾","喔","喙","嗪","嗷","嗉","嘟","嗑","嗫" 237 ,"嗬","嗔","嗦","嗝","嗄","嗯","嗥","嗲","嗳","嗌","嗍","嗨","嗵","嗤","辔","嘞" 238 ,"嘈","嘌","嘁","嘤","嘣","嗾","嘀","嘧","嘭","噘","嘹","噗","嘬","噍","噢","噙" 239 ,"噜","噌","噔","嚆","噤","噱","噫","噻","噼","嚅","嚓","嚯","囔","囗","囝","囡" 240 ,"囵","囫","囹","囿","圄","圊","圉","圜","帏","帙","帔","帑","帱","帻","帼" 241 ,"帷","幄","幔","幛","幞","幡","岌","屺","岍","岐","岖","岈","岘","岙","岑" 242 ,"岚","岜","岵","岢","岽","岬","岫","岱","岣","峁","岷","峄","峒","峤","峋","峥" 243 ,"崂","崃","崧","崦","崮","崤","崞","崆","崛","嵘","崾","崴","崽","嵬","嵛","嵯" 244 ,"嵝","嵫","嵋","嵊","嵩","嵴","嶂","嶙","嶝","豳","嶷","巅","彳","彷","徂","徇" 245 ,"徉","後","徕","徙","徜","徨","徭","徵","徼","衢","彡","犭","犰","犴","犷","犸" 246 ,"狃","狁","狎","狍","狒","狨","狯","狩","狲","狴","狷","猁","狳","猃","狺" 247 ,"狻","猗","猓","猡","猊","猞","猝","猕","猢","猹","猥","猬","猸","猱","獐" 248 ,"獍","獗","獠","獬","獯","獾","舛","夥","飧","夤","夂","饣","饧","饨","饩","饪" 249 ,"饫","饬","饴","饷","饽","馀","馄","馇","馊","馍","馐","馑","馓","馔","馕","庀" 250 ,"庑","庋","庖","庥","庠","庹","庵","庾","庳","赓","廒","廑","廛","廨","廪","膺" 251 ,"忄","忉","忖","忏","怃","忮","怄","忡","忤","忾","怅","怆","忪","忭","忸","怙" 252 ,"怵","怦","怛","怏","怍","怩","怫","怊","怿","怡","恸","恹","恻","恺","恂" 253 ,"恪","恽","悖","悚","悭","悝","悃","悒","悌","悛","惬","悻","悱","惝","惘" 254 ,"惆","惚","悴","愠","愦","愕","愣","惴","愀","愎","愫","慊","慵","憬","憔","憧" 255 ,"憷","懔","懵","忝","隳","闩","闫","闱","闳","闵","闶","闼","闾","阃","阄","阆" 256 ,"阈","阊","阋","阌","阍","阏","阒","阕","阖","阗","阙","阚","丬","爿","戕","氵" 257 ,"汔","汜","汊","沣","沅","沐","沔","沌","汨","汩","汴","汶","沆","沩","泐","泔" 258 ,"沭","泷","泸","泱","泗","沲","泠","泖","泺","泫","泮","沱","泓","泯","泾" 259 ,"洹","洧","洌","浃","浈","洇","洄","洙","洎","洫","浍","洮","洵","洚","浏" 260 ,"浒","浔","洳","涑","浯","涞","涠","浞","涓","涔","浜","浠","浼","浣","渚","淇" 261 ,"淅","淞","渎","涿","淠","渑","淦","淝","淙","渖","涫","渌","涮","渫","湮","湎" 262 ,"湫","溲","湟","溆","湓","湔","渲","渥","湄","滟","溱","溘","滠","漭","滢","溥" 263 ,"溧","溽","溻","溷","滗","溴","滏","溏","滂","溟","潢","潆","潇","漤","漕","滹" 264 ,"漯","漶","潋","潴","漪","漉","漩","澉","澍","澌","潸","潲","潼","潺","濑" 265 ,"濉","澧","澹","澶","濂","濡","濮","濞","濠","濯","瀚","瀣","瀛","瀹","瀵" 266 ,"灏","灞","宀","宄","宕","宓","宥","宸","甯","骞","搴","寤","寮","褰","寰","蹇" 267 ,"謇","辶","迓","迕","迥","迮","迤","迩","迦","迳","迨","逅","逄","逋","逦","逑" 268 ,"逍","逖","逡","逵","逶","逭","逯","遄","遑","遒","遐","遨","遘","遢","遛","暹" 269 ,"遴","遽","邂","邈","邃","邋","彐","彗","彖","彘","尻","咫","屐","屙","孱","屣" 270 ,"屦","羼","弪","弩","弭","艴","弼","鬻","屮","妁","妃","妍","妩","妪","妣" 271 ,"妗","姊","妫","妞","妤","姒","妲","妯","姗","妾","娅","娆","姝","娈","姣" 272 ,"姘","姹","娌","娉","娲","娴","娑","娣","娓","婀","婧","婊","婕","娼","婢","婵" 273 ,"胬","媪","媛","婷","婺","媾","嫫","媲","嫒","嫔","媸","嫠","嫣","嫱","嫖","嫦" 274 ,"嫘","嫜","嬉","嬗","嬖","嬲","嬷","孀","尕","尜","孚","孥","孳","孑","孓","孢" 275 ,"驵","驷","驸","驺","驿","驽","骀","骁","骅","骈","骊","骐","骒","骓","骖","骘" 276 ,"骛","骜","骝","骟","骠","骢","骣","骥","骧","纟","纡","纣","纥","纨","纩" 277 ,"纭","纰","纾","绀","绁","绂","绉","绋","绌","绐","绔","绗","绛","绠","绡" 278 ,"绨","绫","绮","绯","绱","绲","缍","绶","绺","绻","绾","缁","缂","缃","缇","缈" 279 ,"缋","缌","缏","缑","缒","缗","缙","缜","缛","缟","缡","缢","缣","缤","缥","缦" 280 ,"缧","缪","缫","缬","缭","缯","缰","缱","缲","缳","缵","幺","畿","巛","甾","邕" 281 ,"玎","玑","玮","玢","玟","珏","珂","珑","玷","玳","珀","珉","珈","珥","珙","顼" 282 ,"琊","珩","珧","珞","玺","珲","琏","琪","瑛","琦","琥","琨","琰","琮","琬" 283 ,"琛","琚","瑁","瑜","瑗","瑕","瑙","瑷","瑭","瑾","璜","璎","璀","璁","璇" 284 ,"璋","璞","璨","璩","璐","璧","瓒","璺","韪","韫","韬","杌","杓","杞","杈","杩" 285 ,"枥","枇","杪","杳","枘","枧","杵","枨","枞","枭","枋","杷","杼","柰","栉","柘" 286 ,"栊","柩","枰","栌","柙","枵","柚","枳","柝","栀","柃","枸","柢","栎","柁","柽" 287 ,"栲","栳","桠","桡","桎","桢","桄","桤","梃","栝","桕","桦","桁","桧","桀","栾" 288 ,"桊","桉","栩","梵","梏","桴","桷","梓","桫","棂","楮","棼","椟","椠","棹" 289 ,"椤","棰","椋","椁","楗","棣","椐","楱","椹","楠","楂","楝","榄","楫","榀" 290 ,"榘","楸","椴","槌","榇","榈","槎","榉","楦","楣","楹","榛","榧","榻","榫","榭" 291 ,"槔","榱","槁","槊","槟","榕","槠","榍","槿","樯","槭","樗","樘","橥","槲","橄" 292 ,"樾","檠","橐","橛","樵","檎","橹","樽","樨","橘","橼","檑","檐","檩","檗","檫" 293 ,"猷","獒","殁","殂","殇","殄","殒","殓","殍","殚","殛","殡","殪","轫","轭","轱" 294 ,"轲","轳","轵","轶","轸","轷","轹","轺","轼","轾","辁","辂","辄","辇","辋" 295 ,"辍","辎","辏","辘","辚","軎","戋","戗","戛","戟","戢","戡","戥","戤","戬" 296 ,"臧","瓯","瓴","瓿","甏","甑","甓","攴","旮","旯","旰","昊","昙","杲","昃","昕" 297 ,"昀","炅","曷","昝","昴","昱","昶","昵","耆","晟","晔","晁","晏","晖","晡","晗" 298 ,"晷","暄","暌","暧","暝","暾","曛","曜","曦","曩","贲","贳","贶","贻","贽","赀" 299 ,"赅","赆","赈","赉","赇","赍","赕","赙","觇","觊","觋","觌","觎","觏","觐","觑" 300 ,"牮","犟","牝","牦","牯","牾","牿","犄","犋","犍","犏","犒","挈","挲","掰" 301 ,"搿","擘","耄","毪","毳","毽","毵","毹","氅","氇","氆","氍","氕","氘","氙" 302 ,"氚","氡","氩","氤","氪","氲","攵","敕","敫","牍","牒","牖","爰","虢","刖","肟" 303 ,"肜","肓","肼","朊","肽","肱","肫","肭","肴","肷","胧","胨","胩","胪","胛","胂" 304 ,"胄","胙","胍","胗","朐","胝","胫","胱","胴","胭","脍","脎","胲","胼","朕","脒" 305 ,"豚","脶","脞","脬","脘","脲","腈","腌","腓","腴","腙","腚","腱","腠","腩","腼" 306 ,"腽","腭","腧","塍","媵","膈","膂","膑","滕","膣","膪","臌","朦","臊","膻" 307 ,"臁","膦","欤","欷","欹","歃","歆","歙","飑","飒","飓","飕","飙","飚","殳" 308 ,"彀","毂","觳","斐","齑","斓","於","旆","旄","旃","旌","旎","旒","旖","炀","炜" 309 ,"炖","炝","炻","烀","炷","炫","炱","烨","烊","焐","焓","焖","焯","焱","煳","煜" 310 ,"煨","煅","煲","煊","煸","煺","熘","熳","熵","熨","熠","燠","燔","燧","燹","爝" 311 ,"爨","灬","焘","煦","熹","戾","戽","扃","扈","扉","礻","祀","祆","祉","祛","祜" 312 ,"祓","祚","祢","祗","祠","祯","祧","祺","禅","禊","禚","禧","禳","忑","忐" 313 ,"怼","恝","恚","恧","恁","恙","恣","悫","愆","愍","慝","憩","憝","懋","懑" 314 ,"戆","肀","聿","沓","泶","淼","矶","矸","砀","砉","砗","砘","砑","斫","砭","砜" 315 ,"砝","砹","砺","砻","砟","砼","砥","砬","砣","砩","硎","硭","硖","硗","砦","硐" 316 ,"硇","硌","硪","碛","碓","碚","碇","碜","碡","碣","碲","碹","碥","磔","磙","磉" 317 ,"磬","磲","礅","磴","礓","礤","礞","礴","龛","黹","黻","黼","盱","眄","眍","盹" 318 ,"眇","眈","眚","眢","眙","眭","眦","眵","眸","睐","睑","睇","睃","睚","睨" 319 ,"睢","睥","睿","瞍","睽","瞀","瞌","瞑","瞟","瞠","瞰","瞵","瞽","町","畀" 320 ,"畎","畋","畈","畛","畲","畹","疃","罘","罡","罟","詈","罨","罴","罱","罹","羁" 321 ,"罾","盍","盥","蠲","钅","钆","钇","钋","钊","钌","钍","钏","钐","钔","钗","钕" 322 ,"钚","钛","钜","钣","钤","钫","钪","钭","钬","钯","钰","钲","钴","钶","钷","钸" 323 ,"钹","钺","钼","钽","钿","铄","铈","铉","铊","铋","铌","铍","铎","铐","铑","铒" 324 ,"铕","铖","铗","铙","铘","铛","铞","铟","铠","铢","铤","铥","铧","铨","铪" 325 ,"铩","铫","铮","铯","铳","铴","铵","铷","铹","铼","铽","铿","锃","锂","锆" 326 ,"锇","锉","锊","锍","锎","锏","锒","锓","锔","锕","锖","锘","锛","锝","锞","锟" 327 ,"锢","锪","锫","锩","锬","锱","锲","锴","锶","锷","锸","锼","锾","锿","镂","锵" 328 ,"镄","镅","镆","镉","镌","镎","镏","镒","镓","镔","镖","镗","镘","镙","镛","镞" 329 ,"镟","镝","镡","镢","镤","镥","镦","镧","镨","镩","镪","镫","镬","镯","镱","镲" 330 ,"镳","锺","矧","矬","雉","秕","秭","秣","秫","稆","嵇","稃","稂","稞","稔" 331 ,"稹","稷","穑","黏","馥","穰","皈","皎","皓","皙","皤","瓞","瓠","甬","鸠" 332 ,"鸢","鸨","鸩","鸪","鸫","鸬","鸲","鸱","鸶","鸸","鸷","鸹","鸺","鸾","鹁","鹂" 333 ,"鹄","鹆","鹇","鹈","鹉","鹋","鹌","鹎","鹑","鹕","鹗","鹚","鹛","鹜","鹞","鹣" 334 ,"鹦","鹧","鹨","鹩","鹪","鹫","鹬","鹱","鹭","鹳","疒","疔","疖","疠","疝","疬" 335 ,"疣","疳","疴","疸","痄","疱","疰","痃","痂","痖","痍","痣","痨","痦","痤","痫" 336 ,"痧","瘃","痱","痼","痿","瘐","瘀","瘅","瘌","瘗","瘊","瘥","瘘","瘕","瘙" 337 ,"瘛","瘼","瘢","瘠","癀","瘭","瘰","瘿","瘵","癃","瘾","瘳","癍","癞","癔" 338 ,"癜","癖","癫","癯","翊","竦","穸","穹","窀","窆","窈","窕","窦","窠","窬","窨" 339 ,"窭","窳","衤","衩","衲","衽","衿","袂","袢","裆","袷","袼","裉","裢","裎","裣" 340 ,"裥","裱","褚","裼","裨","裾","裰","褡","褙","褓","褛","褊","褴","褫","褶","襁" 341 ,"襦","襻","疋","胥","皲","皴","矜","耒","耔","耖","耜","耠","耢","耥","耦","耧" 342 ,"耩","耨","耱","耋","耵","聃","聆","聍","聒","聩","聱","覃","顸","颀","颃" 343 ,"颉","颌","颍","颏","颔","颚","颛","颞","颟","颡","颢","颥","颦","虍","虔" 344 ,"虬","虮","虿","虺","虼","虻","蚨","蚍","蚋","蚬","蚝","蚧","蚣","蚪","蚓","蚩" 345 ,"蚶","蛄","蚵","蛎","蚰","蚺","蚱","蚯","蛉","蛏","蚴","蛩","蛱","蛲","蛭","蛳" 346 ,"蛐","蜓","蛞","蛴","蛟","蛘","蛑","蜃","蜇","蛸","蜈","蜊","蜍","蜉","蜣","蜻" 347 ,"蜞","蜥","蜮","蜚","蜾","蝈","蜴","蜱","蜩","蜷","蜿","螂","蜢","蝽","蝾","蝻" 348 ,"蝠","蝰","蝌","蝮","螋","蝓","蝣","蝼","蝤","蝙","蝥","螓","螯","螨","蟒" 349 ,"蟆","螈","螅","螭","螗","螃","螫","蟥","螬","螵","螳","蟋","蟓","螽","蟑" 350 ,"蟀","蟊","蟛","蟪","蟠","蟮","蠖","蠓","蟾","蠊","蠛","蠡","蠹","蠼","缶","罂" 351 ,"罄","罅","舐","竺","竽","笈","笃","笄","笕","笊","笫","笏","筇","笸","笪","笙" 352 ,"笮","笱","笠","笥","笤","笳","笾","笞","筘","筚","筅","筵","筌","筝","筠","筮" 353 ,"筻","筢","筲","筱","箐","箦","箧","箸","箬","箝","箨","箅","箪","箜","箢","箫" 354 ,"箴","篑","篁","篌","篝","篚","篥","篦","篪","簌","篾","篼","簏","簖","簋" 355 ,"簟","簪","簦","簸","籁","籀","臾","舁","舂","舄","臬","衄","舡","舢","舣" 356 ,"舭","舯","舨","舫","舸","舻","舳","舴","舾","艄","艉","艋","艏","艚","艟","艨" 357 ,"衾","袅","袈","裘","裟","襞","羝","羟","羧","羯","羰","羲","籼","敉","粑","粝" 358 ,"粜","粞","粢","粲","粼","粽","糁","糇","糌","糍","糈","糅","糗","糨","艮","暨" 359 ,"羿","翎","翕","翥","翡","翦","翩","翮","翳","糸","絷","綦","綮","繇","纛","麸" 360 ,"麴","赳","趄","趔","趑","趱","赧","赭","豇","豉","酊","酐","酎","酏","酤" 361 ,"酢","酡","酰","酩","酯","酽","酾","酲","酴","酹","醌","醅","醐","醍","醑" 362 ,"醢","醣","醪","醭","醮","醯","醵","醴","醺","豕","鹾","趸","跫","踅","蹙","蹩" 363 ,"趵","趿","趼","趺","跄","跖","跗","跚","跞","跎","跏","跛","跆","跬","跷","跸" 364 ,"跣","跹","跻","跤","踉","跽","踔","踝","踟","踬","踮","踣","踯","踺","蹀","踹" 365 ,"踵","踽","踱","蹉","蹁","蹂","蹑","蹒","蹊","蹰","蹶","蹼","蹯","蹴","躅","躏" 366 ,"躔","躐","躜","躞","豸","貂","貊","貅","貘","貔","斛","觖","觞","觚","觜" 367 ,"觥","觫","觯","訾","謦","靓","雩","雳","雯","霆","霁","霈","霏","霎","霪" 368 ,"霭","霰","霾","龀","龃","龅","龆","龇","龈","龉","龊","龌","黾","鼋","鼍","隹" 369 ,"隼","隽","雎","雒","瞿","雠","銎","銮","鋈","錾","鍪","鏊","鎏","鐾","鑫","鱿" 370 ,"鲂","鲅","鲆","鲇","鲈","稣","鲋","鲎","鲐","鲑","鲒","鲔","鲕","鲚","鲛","鲞" 371 ,"鲟","鲠","鲡","鲢","鲣","鲥","鲦","鲧","鲨","鲩","鲫","鲭","鲮","鲰","鲱","鲲" 372 ,"鲳","鲴","鲵","鲶","鲷","鲺","鲻","鲼","鲽","鳄","鳅","鳆","鳇","鳊","鳋" 373 ,"鳌","鳍","鳎","鳏","鳐","鳓","鳔","鳕","鳗","鳘","鳙","鳜","鳝","鳟","鳢" 374 ,"靼","鞅","鞑","鞒","鞔","鞯","鞫","鞣","鞲","鞴","骱","骰","骷","鹘","骶","骺" 375 ,"骼","髁","髀","髅","髂","髋","髌","髑","魅","魃","魇","魉","魈","魍","魑","飨" 376 ,"餍","餮","饕","饔","髟","髡","髦","髯","髫","髻","髭","髹","鬈","鬏","鬓","鬟" 377 ,"鬣","麽","麾","縻","麂","麇","麈","麋","麒","鏖","麝","麟","黛","黜","黝","黠" 378 ,"黟","黢","黩","黧","黥","黪","黯","鼢","鼬","鼯","鼹","鼷","鼽","鼾","齄" 379 }; 380 381 /// <summary> 382 /// 二级汉字对应拼音数组 383 /// </summary> 384 private static string[] otherPinYin = new string[] 385 { 386 "Chu","Ji","Wu","Gai","Nian","Sa","Pi","Gen","Cheng","Ge","Nao","E","Shu","Yu","Pie","Bi", 387 "Tuo","Yao","Yao","Zhi","Di","Xin","Yin","Kui","Yu","Gao","Tao","Dian","Ji","Nai","Nie","Ji", 388 "Qi","Mi","Bei","Se","Gu","Ze","She","Cuo","Yan","Jue","Si","Ye","Yan","Fang","Po","Gui", 389 "Kui","Bian","Ze","Gua","You","Ce","Yi","Wen","Jing","Ku","Gui","Kai","La","Ji","Yan","Wan", 390 "Kuai","Piao","Jue","Qiao","Huo","Yi","Tong","Wang","Dan","Ding","Zhang","Le","Sa","Yi","Mu","Ren", 391 "Yu","Pi","Ya","Wa","Wu","Chang","Cang","Kang","Zhu","Ning","Ka","You","Yi","Gou","Tong","Tuo", 392 "Ni","Ga","Ji","Er","You","Kua","Kan","Zhu","Yi","Tiao","Chai","Jiao","Nong","Mou","Chou","Yan", 393 "Li","Qiu","Li","Yu","Ping","Yong","Si","Feng","Qian","Ruo","Pai","Zhuo","Shu","Luo","Wo","Bi", 394 "Ti","Guan","Kong","Ju","Fen","Yan","Xie","Ji","Wei","Zong","Lou","Tang","Bin","Nuo","Chi","Xi", 395 "Jing","Jian","Jiao","Jiu","Tong","Xuan","Dan","Tong","Tun","She","Qian","Zu","Yue","Cuan","Di","Xi", 396 "Xun","Hong","Guo","Chan","Kui","Bao","Pu","Hong","Fu","Fu","Su","Si","Wen","Yan","Bo","Gun", 397 "Mao","Xie","Luan","Pou","Bing","Ying","Luo","Lei","Liang","Hu","Lie","Xian","Song","Ping","Zhong","Ming", 398 "Yan","Jie","Hong","Shan","Ou","Ju","Ne","Gu","He","Di","Zhao","Qu","Dai","Kuang","Lei","Gua", 399 "Jie","Hui","Shen","Gou","Quan","Zheng","Hun","Xu","Qiao","Gao","Kuang","Ei","Zou","Zhuo","Wei","Yu", 400 "Shen","Chan","Sui","Chen","Jian","Xue","Ye","E","Yu","Xuan","An","Di","Zi","Pian","Mo","Dang", 401 "Su","Shi","Mi","Zhe","Jian","Zen","Qiao","Jue","Yan","Zhan","Chen","Dan","Jin","Zuo","Wu","Qian", 402 "Jing","Ban","Yan","Zuo","Bei","Jing","Gai","Zhi","Nie","Zou","Chui","Pi","Wei","Huang","Wei","Xi", 403 "Han","Qiong","Kuang","Mang","Wu","Fang","Bing","Pi","Bei","Ye","Di","Tai","Jia","Zhi","Zhu","Kuai", 404 "Qie","Xun","Yun","Li","Ying","Gao","Xi","Fu","Pi","Tan","Yan","Juan","Yan","Yin","Zhang","Po", 405 "Shan","Zou","Ling","Feng","Chu","Huan","Mai","Qu","Shao","He","Ge","Meng","Xu","Xie","Sou","Xie", 406 "Jue","Jian","Qian","Dang","Chang","Si","Bian","Ben","Qiu","Ben","E","Fa","Shu","Ji","Yong","He", 407 "Wei","Wu","Ge","Zhen","Kuang","Pi","Yi","Li","Qi","Ban","Gan","Long","Dian","Lu","Che","Di", 408 "Tuo","Ni","Mu","Ao","Ya","Die","Dong","Kai","Shan","Shang","Nao","Gai","Yin","Cheng","Shi","Guo", 409 "Xun","Lie","Yuan","Zhi","An","Yi","Pi","Nian","Peng","Tu","Sao","Dai","Ku","Die","Yin","Leng", 410 "Hou","Ge","Yuan","Man","Yong","Liang","Chi","Xin","Pi","Yi","Cao","Jiao","Nai","Du","Qian","Ji", 411 "Wan","Xiong","Qi","Xiang","Fu","Yuan","Yun","Fei","Ji","Li","E","Ju","Pi","Zhi","Rui","Xian", 412 "Chang","Cong","Qin","Wu","Qian","Qi","Shan","Bian","Zhu","Kou","Yi","Mo","Gan","Pie","Long","Ba", 413 "Mu","Ju","Ran","Qing","Chi","Fu","Ling","Niao","Yin","Mao","Ying","Qiong","Min","Tiao","Qian","Yi", 414 "Rao","Bi","Zi","Ju","Tong","Hui","Zhu","Ting","Qiao","Fu","Ren","Xing","Quan","Hui","Xun","Ming", 415 "Qi","Jiao","Chong","Jiang","Luo","Ying","Qian","Gen","Jin","Mai","Sun","Hong","Zhou","Kan","Bi","Shi", 416 "Wo","You","E","Mei","You","Li","Tu","Xian","Fu","Sui","You","Di","Shen","Guan","Lang","Ying", 417 "Chun","Jing","Qi","Xi","Song","Jin","Nai","Qi","Ba","Shu","Chang","Tie","Yu","Huan","Bi","Fu", 418 "Tu","Dan","Cui","Yan","Zu","Dang","Jian","Wan","Ying","Gu","Han","Qia","Feng","Shen","Xiang","Wei", 419 "Chan","Kai","Qi","Kui","Xi","E","Bao","Pa","Ting","Lou","Pai","Xuan","Jia","Zhen","Shi","Ru", 420 "Mo","En","Bei","Weng","Hao","Ji","Li","Bang","Jian","Shuo","Lang","Ying","Yu","Su","Meng","Dou", 421 "Xi","Lian","Cu","Lin","Qu","Kou","Xu","Liao","Hui","Xun","Jue","Rui","Zui","Ji","Meng","Fan", 422 "Qi","Hong","Xie","Hong","Wei","Yi","Weng","Sou","Bi","Hao","Tai","Ru","Xun","Xian","Gao","Li", 423 "Huo","Qu","Heng","Fan","Nie","Mi","Gong","Yi","Kuang","Lian","Da","Yi","Xi","Zang","Pao","You", 424 "Liao","Ga","Gan","Ti","Men","Tuan","Chen","Fu","Pin","Niu","Jie","Jiao","Za","Yi","Lv","Jun", 425 "Tian","Ye","Ai","Na","Ji","Guo","Bai","Ju","Pou","Lie","Qian","Guan","Die","Zha","Ya","Qin", 426 "Yu","An","Xuan","Bing","Kui","Yuan","Shu","En","Chuai","Jian","Shuo","Zhan","Nuo","Sang","Luo","Ying", 427 "Zhi","Han","Zhe","Xie","Lu","Zun","Cuan","Gan","Huan","Pi","Xing","Zhuo","Huo","Zuan","Nang","Yi", 428 "Te","Dai","Shi","Bu","Chi","Ji","Kou","Dao","Le","Zha","A","Yao","Fu","Mu","Yi","Tai", 429 "Li","E","Bi","Bei","Guo","Qin","Yin","Za","Ka","Ga","Gua","Ling","Dong","Ning","Duo","Nao", 430 "You","Si","Kuang","Ji","Shen","Hui","Da","Lie","Yi","Xiao","Bi","Ci","Guang","Yue","Xiu","Yi", 431 "Pai","Kuai","Duo","Ji","Mie","Mi","Zha","Nong","Gen","Mou","Mai","Chi","Lao","Geng","En","Zha", 432 "Suo","Zao","Xi","Zuo","Ji","Feng","Ze","Nuo","Miao","Lin","Zhuan","Zhou","Tao","Hu","Cui","Sha", 433 "Yo","Dan","Bo","Ding","Lang","Li","Shua","Chuo","Die","Da","Nan","Li","Kui","Jie","Yong","Kui", 434 "Jiu","Sou","Yin","Chi","Jie","Lou","Ku","Wo","Hui","Qin","Ao","Su","Du","Ke","Nie","He", 435 "Chen","Suo","Ge","A","En","Hao","Dia","Ai","Ai","Suo","Hei","Tong","Chi","Pei","Lei","Cao", 436 "Piao","Qi","Ying","Beng","Sou","Di","Mi","Peng","Jue","Liao","Pu","Chuai","Jiao","O","Qin","Lu", 437 "Ceng","Deng","Hao","Jin","Jue","Yi","Sai","Pi","Ru","Cha","Huo","Nang","Wei","Jian","Nan","Lun", 438 "Hu","Ling","You","Yu","Qing","Yu","Huan","Wei","Zhi","Pei","Tang","Dao","Ze","Guo","Wei","Wo", 439 "Man","Zhang","Fu","Fan","Ji","Qi","Qian","Qi","Qu","Ya","Xian","Ao","Cen","Lan","Ba","Hu", 440 "Ke","Dong","Jia","Xiu","Dai","Gou","Mao","Min","Yi","Dong","Qiao","Xun","Zheng","Lao","Lai","Song", 441 "Yan","Gu","Xiao","Guo","Kong","Jue","Rong","Yao","Wai","Zai","Wei","Yu","Cuo","Lou","Zi","Mei", 442 "Sheng","Song","Ji","Zhang","Lin","Deng","Bin","Yi","Dian","Chi","Pang","Cu","Xun","Yang","Hou","Lai", 443 "Xi","Chang","Huang","Yao","Zheng","Jiao","Qu","San","Fan","Qiu","An","Guang","Ma","Niu","Yun","Xia", 444 "Pao","Fei","Rong","Kuai","Shou","Sun","Bi","Juan","Li","Yu","Xian","Yin","Suan","Yi","Guo","Luo", 445 "Ni","She","Cu","Mi","Hu","Cha","Wei","Wei","Mei","Nao","Zhang","Jing","Jue","Liao","Xie","Xun", 446 "Huan","Chuan","Huo","Sun","Yin","Dong","Shi","Tang","Tun","Xi","Ren","Yu","Chi","Yi","Xiang","Bo", 447 "Yu","Hun","Zha","Sou","Mo","Xiu","Jin","San","Zhuan","Nang","Pi","Wu","Gui","Pao","Xiu","Xiang", 448 "Tuo","An","Yu","Bi","Geng","Ao","Jin","Chan","Xie","Lin","Ying","Shu","Dao","Cun","Chan","Wu", 449 "Zhi","Ou","Chong","Wu","Kai","Chang","Chuang","Song","Bian","Niu","Hu","Chu","Peng","Da","Yang","Zuo", 450 "Ni","Fu","Chao","Yi","Yi","Tong","Yan","Ce","Kai","Xun","Ke","Yun","Bei","Song","Qian","Kui", 451 "Kun","Yi","Ti","Quan","Qie","Xing","Fei","Chang","Wang","Chou","Hu","Cui","Yun","Kui","E","Leng", 452 "Zhui","Qiao","Bi","Su","Qie","Yong","Jing","Qiao","Chong","Chu","Lin","Meng","Tian","Hui","Shuan","Yan", 453 "Wei","Hong","Min","Kang","Ta","Lv","Kun","Jiu","Lang","Yu","Chang","Xi","Wen","Hun","E","Qu", 454 "Que","He","Tian","Que","Kan","Jiang","Pan","Qiang","San","Qi","Si","Cha","Feng","Yuan","Mu","Mian", 455 "Dun","Mi","Gu","Bian","Wen","Hang","Wei","Le","Gan","Shu","Long","Lu","Yang","Si","Duo","Ling", 456 "Mao","Luo","Xuan","Pan","Duo","Hong","Min","Jing","Huan","Wei","Lie","Jia","Zhen","Yin","Hui","Zhu", 457 "Ji","Xu","Hui","Tao","Xun","Jiang","Liu","Hu","Xun","Ru","Su","Wu","Lai","Wei","Zhuo","Juan", 458 "Cen","Bang","Xi","Mei","Huan","Zhu","Qi","Xi","Song","Du","Zhuo","Pei","Mian","Gan","Fei","Cong", 459 "Shen","Guan","Lu","Shuan","Xie","Yan","Mian","Qiu","Sou","Huang","Xu","Pen","Jian","Xuan","Wo","Mei", 460 "Yan","Qin","Ke","She","Mang","Ying","Pu","Li","Ru","Ta","Hun","Bi","Xiu","Fu","Tang","Pang", 461 "Ming","Huang","Ying","Xiao","Lan","Cao","Hu","Luo","Huan","Lian","Zhu","Yi","Lu","Xuan","Gan","Shu", 462 "Si","Shan","Shao","Tong","Chan","Lai","Sui","Li","Dan","Chan","Lian","Ru","Pu","Bi","Hao","Zhuo", 463 "Han","Xie","Ying","Yue","Fen","Hao","Ba","Bao","Gui","Dang","Mi","You","Chen","Ning","Jian","Qian", 464 "Wu","Liao","Qian","Huan","Jian","Jian","Zou","Ya","Wu","Jiong","Ze","Yi","Er","Jia","Jing","Dai", 465 "Hou","Pang","Bu","Li","Qiu","Xiao","Ti","Qun","Kui","Wei","Huan","Lu","Chuan","Huang","Qiu","Xia", 466 "Ao","Gou","Ta","Liu","Xian","Lin","Ju","Xie","Miao","Sui","La","Ji","Hui","Tuan","Zhi","Kao", 467 "Zhi","Ji","E","Chan","Xi","Ju","Chan","Jing","Nu","Mi","Fu","Bi","Yu","Che","Shuo","Fei", 468 "Yan","Wu","Yu","Bi","Jin","Zi","Gui","Niu","Yu","Si","Da","Zhou","Shan","Qie","Ya","Rao", 469 "Shu","Luan","Jiao","Pin","Cha","Li","Ping","Wa","Xian","Suo","Di","Wei","E","Jing","Biao","Jie", 470 "Chang","Bi","Chan","Nu","Ao","Yuan","Ting","Wu","Gou","Mo","Pi","Ai","Pin","Chi","Li","Yan", 471 "Qiang","Piao","Chang","Lei","Zhang","Xi","Shan","Bi","Niao","Mo","Shuang","Ga","Ga","Fu","Nu","Zi", 472 "Jie","Jue","Bao","Zang","Si","Fu","Zou","Yi","Nu","Dai","Xiao","Hua","Pian","Li","Qi","Ke", 473 "Zhui","Can","Zhi","Wu","Ao","Liu","Shan","Biao","Cong","Chan","Ji","Xiang","Jiao","Yu","Zhou","Ge", 474 "Wan","Kuang","Yun","Pi","Shu","Gan","Xie","Fu","Zhou","Fu","Chu","Dai","Ku","Hang","Jiang","Geng", 475 "Xiao","Ti","Ling","Qi","Fei","Shang","Gun","Duo","Shou","Liu","Quan","Wan","Zi","Ke","Xiang","Ti", 476 "Miao","Hui","Si","Bian","Gou","Zhui","Min","Jin","Zhen","Ru","Gao","Li","Yi","Jian","Bin","Piao", 477 "Man","Lei","Miao","Sao","Xie","Liao","Zeng","Jiang","Qian","Qiao","Huan","Zuan","Yao","Ji","Chuan","Zai", 478 "Yong","Ding","Ji","Wei","Bin","Min","Jue","Ke","Long","Dian","Dai","Po","Min","Jia","Er","Gong", 479 "Xu","Ya","Heng","Yao","Luo","Xi","Hui","Lian","Qi","Ying","Qi","Hu","Kun","Yan","Cong","Wan", 480 "Chen","Ju","Mao","Yu","Yuan","Xia","Nao","Ai","Tang","Jin","Huang","Ying","Cui","Cong","Xuan","Zhang", 481 "Pu","Can","Qu","Lu","Bi","Zan","Wen","Wei","Yun","Tao","Wu","Shao","Qi","Cha","Ma","Li", 482 "Pi","Miao","Yao","Rui","Jian","Chu","Cheng","Cong","Xiao","Fang","Pa","Zhu","Nai","Zhi","Zhe","Long", 483 "Jiu","Ping","Lu","Xia","Xiao","You","Zhi","Tuo","Zhi","Ling","Gou","Di","Li","Tuo","Cheng","Kao", 484 "Lao","Ya","Rao","Zhi","Zhen","Guang","Qi","Ting","Gua","Jiu","Hua","Heng","Gui","Jie","Luan","Juan", 485 "An","Xu","Fan","Gu","Fu","Jue","Zi","Suo","Ling","Chu","Fen","Du","Qian","Zhao","Luo","Chui", 486 "Liang","Guo","Jian","Di","Ju","Cou","Zhen","Nan","Zha","Lian","Lan","Ji","Pin","Ju","Qiu","Duan", 487 "Chui","Chen","Lv","Cha","Ju","Xuan","Mei","Ying","Zhen","Fei","Ta","Sun","Xie","Gao","Cui","Gao", 488 "Shuo","Bin","Rong","Zhu","Xie","Jin","Qiang","Qi","Chu","Tang","Zhu","Hu","Gan","Yue","Qing","Tuo", 489 "Jue","Qiao","Qin","Lu","Zun","Xi","Ju","Yuan","Lei","Yan","Lin","Bo","Cha","You","Ao","Mo", 490 "Cu","Shang","Tian","Yun","Lian","Piao","Dan","Ji","Bin","Yi","Ren","E","Gu","Ke","Lu","Zhi", 491 "Yi","Zhen","Hu","Li","Yao","Shi","Zhi","Quan","Lu","Zhe","Nian","Wang","Chuo","Zi","Cou","Lu", 492 "Lin","Wei","Jian","Qiang","Jia","Ji","Ji","Kan","Deng","Gai","Jian","Zang","Ou","Ling","Bu","Beng", 493 "Zeng","Pi","Po","Ga","La","Gan","Hao","Tan","Gao","Ze","Xin","Yun","Gui","He","Zan","Mao", 494 "Yu","Chang","Ni","Qi","Sheng","Ye","Chao","Yan","Hui","Bu","Han","Gui","Xuan","Kui","Ai","Ming", 495 "Tun","Xun","Yao","Xi","Nang","Ben","Shi","Kuang","Yi","Zhi","Zi","Gai","Jin","Zhen","Lai","Qiu", 496 "Ji","Dan","Fu","Chan","Ji","Xi","Di","Yu","Gou","Jin","Qu","Jian","Jiang","Pin","Mao","Gu", 497 "Wu","Gu","Ji","Ju","Jian","Pian","Kao","Qie","Suo","Bai","Ge","Bo","Mao","Mu","Cui","Jian", 498 "San","Shu","Chang","Lu","Pu","Qu","Pie","Dao","Xian","Chuan","Dong","Ya","Yin","Ke","Yun","Fan", 499 "Chi","Jiao","Du","Die","You","Yuan","Guo","Yue","Wo","Rong","Huang","Jing","Ruan","Tai","Gong","Zhun", 500 "Na","Yao","Qian","Long","Dong","Ka","Lu","Jia","Shen","Zhou","Zuo","Gua","Zhen","Qu","Zhi","Jing", 501 "Guang","Dong","Yan","Kuai","Sa","Hai","Pian","Zhen","Mi","Tun","Luo","Cuo","Pao","Wan","Niao","Jing", 502 "Yan","Fei","Yu","Zong","Ding","Jian","Cou","Nan","Mian","Wa","E","Shu","Cheng","Ying","Ge","Lv", 503 "Bin","Teng","Zhi","Chuai","Gu","Meng","Sao","Shan","Lian","Lin","Yu","Xi","Qi","Sha","Xin","Xi", 504 "Biao","Sa","Ju","Sou","Biao","Biao","Shu","Gou","Gu","Hu","Fei","Ji","Lan","Yu","Pei","Mao", 505 "Zhan","Jing","Ni","Liu","Yi","Yang","Wei","Dun","Qiang","Shi","Hu","Zhu","Xuan","Tai","Ye","Yang", 506 "Wu","Han","Men","Chao","Yan","Hu","Yu","Wei","Duan","Bao","Xuan","Bian","Tui","Liu","Man","Shang", 507 "Yun","Yi","Yu","Fan","Sui","Xian","Jue","Cuan","Huo","Tao","Xu","Xi","Li","Hu","Jiong","Hu", 508 "Fei","Shi","Si","Xian","Zhi","Qu","Hu","Fu","Zuo","Mi","Zhi","Ci","Zhen","Tiao","Qi","Chan", 509 "Xi","Zhuo","Xi","Rang","Te","Tan","Dui","Jia","Hui","Nv","Nin","Yang","Zi","Que","Qian","Min", 510 "Te","Qi","Dui","Mao","Men","Gang","Yu","Yu","Ta","Xue","Miao","Ji","Gan","Dang","Hua","Che", 511 "Dun","Ya","Zhuo","Bian","Feng","Fa","Ai","Li","Long","Zha","Tong","Di","La","Tuo","Fu","Xing", 512 "Mang","Xia","Qiao","Zhai","Dong","Nao","Ge","Wo","Qi","Dui","Bei","Ding","Chen","Zhou","Jie","Di", 513 "Xuan","Bian","Zhe","Gun","Sang","Qing","Qu","Dun","Deng","Jiang","Ca","Meng","Bo","Kan","Zhi","Fu", 514 "Fu","Xu","Mian","Kou","Dun","Miao","Dan","Sheng","Yuan","Yi","Sui","Zi","Chi","Mou","Lai","Jian", 515 "Di","Suo","Ya","Ni","Sui","Pi","Rui","Sou","Kui","Mao","Ke","Ming","Piao","Cheng","Kan","Lin", 516 "Gu","Ding","Bi","Quan","Tian","Fan","Zhen","She","Wan","Tuan","Fu","Gang","Gu","Li","Yan","Pi", 517 "Lan","Li","Ji","Zeng","He","Guan","Juan","Jin","Ga","Yi","Po","Zhao","Liao","Tu","Chuan","Shan", 518 "Men","Chai","Nv","Bu","Tai","Ju","Ban","Qian","Fang","Kang","Dou","Huo","Ba","Yu","Zheng","Gu", 519 "Ke","Po","Bu","Bo","Yue","Mu","Tan","Dian","Shuo","Shi","Xuan","Ta","Bi","Ni","Pi","Duo", 520 "Kao","Lao","Er","You","Cheng","Jia","Nao","Ye","Cheng","Diao","Yin","Kai","Zhu","Ding","Diu","Hua", 521 "Quan","Ha","Sha","Diao","Zheng","Se","Chong","Tang","An","Ru","Lao","Lai","Te","Keng","Zeng","Li", 522 "Gao","E","Cuo","Lve","Liu","Kai","Jian","Lang","Qin","Ju","A","Qiang","Nuo","Ben","De","Ke", 523 "Kun","Gu","Huo","Pei","Juan","Tan","Zi","Qie","Kai","Si","E","Cha","Sou","Huan","Ai","Lou", 524 "Qiang","Fei","Mei","Mo","Ge","Juan","Na","Liu","Yi","Jia","Bin","Biao","Tang","Man","Luo","Yong", 525 "Chuo","Xuan","Di","Tan","Jue","Pu","Lu","Dui","Lan","Pu","Cuan","Qiang","Deng","Huo","Zhuo","Yi", 526 "Cha","Biao","Zhong","Shen","Cuo","Zhi","Bi","Zi","Mo","Shu","Lv","Ji","Fu","Lang","Ke","Ren", 527 "Zhen","Ji","Se","Nian","Fu","Rang","Gui","Jiao","Hao","Xi","Po","Die","Hu","Yong","Jiu","Yuan", 528 "Bao","Zhen","Gu","Dong","Lu","Qu","Chi","Si","Er","Zhi","Gua","Xiu","Luan","Bo","Li","Hu", 529 "Yu","Xian","Ti","Wu","Miao","An","Bei","Chun","Hu","E","Ci","Mei","Wu","Yao","Jian","Ying", 530 "Zhe","Liu","Liao","Jiao","Jiu","Yu","Hu","Lu","Guan","Bing","Ding","Jie","Li","Shan","Li","You", 531 "Gan","Ke","Da","Zha","Pao","Zhu","Xuan","Jia","Ya","Yi","Zhi","Lao","Wu","Cuo","Xian","Sha", 532 "Zhu","Fei","Gu","Wei","Yu","Yu","Dan","La","Yi","Hou","Chai","Lou","Jia","Sao","Chi","Mo", 533 "Ban","Ji","Huang","Biao","Luo","Ying","Zhai","Long","Yin","Chou","Ban","Lai","Yi","Dian","Pi","Dian", 534 "Qu","Yi","Song","Xi","Qiong","Zhun","Bian","Yao","Tiao","Dou","Ke","Yu","Xun","Ju","Yu","Yi", 535 "Cha","Na","Ren","Jin","Mei","Pan","Dang","Jia","Ge","Ken","Lian","Cheng","Lian","Jian","Biao","Chu", 536 "Ti","Bi","Ju","Duo","Da","Bei","Bao","Lv","Bian","Lan","Chi","Zhe","Qiang","Ru","Pan","Ya", 537 "Xu","Jun","Cun","Jin","Lei","Zi","Chao","Si","Huo","Lao","Tang","Ou","Lou","Jiang","Nou","Mo", 538 "Die","Ding","Dan","Ling","Ning","Guo","Kui","Ao","Qin","Han","Qi","Hang","Jie","He","Ying","Ke", 539 "Han","E","Zhuan","Nie","Man","Sang","Hao","Ru","Pin","Hu","Qian","Qiu","Ji","Chai","Hui","Ge", 540 "Meng","Fu","Pi","Rui","Xian","Hao","Jie","Gong","Dou","Yin","Chi","Han","Gu","Ke","Li","You", 541 "Ran","Zha","Qiu","Ling","Cheng","You","Qiong","Jia","Nao","Zhi","Si","Qu","Ting","Kuo","Qi","Jiao", 542 "Yang","Mou","Shen","Zhe","Shao","Wu","Li","Chu","Fu","Qiang","Qing","Qi","Xi","Yu","Fei","Guo", 543 "Guo","Yi","Pi","Tiao","Quan","Wan","Lang","Meng","Chun","Rong","Nan","Fu","Kui","Ke","Fu","Sou", 544 "Yu","You","Lou","You","Bian","Mou","Qin","Ao","Man","Mang","Ma","Yuan","Xi","Chi","Tang","Pang", 545 "Shi","Huang","Cao","Piao","Tang","Xi","Xiang","Zhong","Zhang","Shuai","Mao","Peng","Hui","Pan","Shan","Huo", 546 "Meng","Chan","Lian","Mie","Li","Du","Qu","Fou","Ying","Qing","Xia","Shi","Zhu","Yu","Ji","Du", 547 "Ji","Jian","Zhao","Zi","Hu","Qiong","Po","Da","Sheng","Ze","Gou","Li","Si","Tiao","Jia","Bian", 548 "Chi","Kou","Bi","Xian","Yan","Quan","Zheng","Jun","Shi","Gang","Pa","Shao","Xiao","Qing","Ze","Qie", 549 "Zhu","Ruo","Qian","Tuo","Bi","Dan","Kong","Wan","Xiao","Zhen","Kui","Huang","Hou","Gou","Fei","Li", 550 "Bi","Chi","Su","Mie","Dou","Lu","Duan","Gui","Dian","Zan","Deng","Bo","Lai","Zhou","Yu","Yu", 551 "Chong","Xi","Nie","Nv","Chuan","Shan","Yi","Bi","Zhong","Ban","Fang","Ge","Lu","Zhu","Ze","Xi", 552 "Shao","Wei","Meng","Shou","Cao","Chong","Meng","Qin","Niao","Jia","Qiu","Sha","Bi","Di","Qiang","Suo", 553 "Jie","Tang","Xi","Xian","Mi","Ba","Li","Tiao","Xi","Zi","Can","Lin","Zong","San","Hou","Zan", 554 "Ci","Xu","Rou","Qiu","Jiang","Gen","Ji","Yi","Ling","Xi","Zhu","Fei","Jian","Pian","He","Yi", 555 "Jiao","Zhi","Qi","Qi","Yao","Dao","Fu","Qu","Jiu","Ju","Lie","Zi","Zan","Nan","Zhe","Jiang", 556 "Chi","Ding","Gan","Zhou","Yi","Gu","Zuo","Tuo","Xian","Ming","Zhi","Yan","Shai","Cheng","Tu","Lei", 557 "Kun","Pei","Hu","Ti","Xu","Hai","Tang","Lao","Bu","Jiao","Xi","Ju","Li","Xun","Shi","Cuo", 558 "Dun","Qiong","Xue","Cu","Bie","Bo","Ta","Jian","Fu","Qiang","Zhi","Fu","Shan","Li","Tuo","Jia", 559 "Bo","Tai","Kui","Qiao","Bi","Xian","Xian","Ji","Jiao","Liang","Ji","Chuo","Huai","Chi","Zhi","Dian", 560 "Bo","Zhi","Jian","Die","Chuai","Zhong","Ju","Duo","Cuo","Pian","Rou","Nie","Pan","Qi","Chu","Jue", 561 "Pu","Fan","Cu","Zhu","Lin","Chan","Lie","Zuan","Xie","Zhi","Diao","Mo","Xiu","Mo","Pi","Hu", 562 "Jue","Shang","Gu","Zi","Gong","Su","Zhi","Zi","Qing","Liang","Yu","Li","Wen","Ting","Ji","Pei", 563 "Fei","Sha","Yin","Ai","Xian","Mai","Chen","Ju","Bao","Tiao","Zi","Yin","Yu","Chuo","Wo","Mian", 564 "Yuan","Tuo","Zhui","Sun","Jun","Ju","Luo","Qu","Chou","Qiong","Luan","Wu","Zan","Mou","Ao","Liu", 565 "Bei","Xin","You","Fang","Ba","Ping","Nian","Lu","Su","Fu","Hou","Tai","Gui","Jie","Wei","Er", 566 "Ji","Jiao","Xiang","Xun","Geng","Li","Lian","Jian","Shi","Tiao","Gun","Sha","Huan","Ji","Qing","Ling", 567 "Zou","Fei","Kun","Chang","Gu","Ni","Nian","Diao","Shi","Zi","Fen","Die","E","Qiu","Fu","Huang", 568 "Bian","Sao","Ao","Qi","Ta","Guan","Yao","Le","Biao","Xue","Man","Min","Yong","Gui","Shan","Zun", 569 "Li","Da","Yang","Da","Qiao","Man","Jian","Ju","Rou","Gou","Bei","Jie","Tou","Ku","Gu","Di", 570 "Hou","Ge","Ke","Bi","Lou","Qia","Kuan","Bin","Du","Mei","Ba","Yan","Liang","Xiao","Wang","Chi", 571 "Xiang","Yan","Tie","Tao","Yong","Biao","Kun","Mao","Ran","Tiao","Ji","Zi","Xiu","Quan","Jiu","Bin", 572 "Huan","Lie","Me","Hui","Mi","Ji","Jun","Zhu","Mi","Qi","Ao","She","Lin","Dai","Chu","You", 573 "Xia","Yi","Qu","Du","Li","Qing","Can","An","Fen","You","Wu","Yan","Xi","Qiu","Han","Zha" 574 }; 575 #endregion 二级汉字 576 #region 变量定义 577 // GB2312-80 标准规范中第一个汉字的机内码.即"啊"的机内码 578 private const int firstChCode = -20319; 579 // GB2312-80 标准规范中最后一个汉字的机内码.即"齄"的机内码 580 private const int lastChCode = -2050; 581 // GB2312-80 标准规范中最后一个一级汉字的机内码.即"座"的机内码 582 private const int lastOfOneLevelChCode = -10247; 583 // 配置中文字符 584 //static Regex regex = new Regex("[\u4e00-\u9fa5]$"); 585 586 #endregion 587 #endregion 588 589 /// <summary> 590 /// 取拼音第一个字段 591 /// </summary> 592 /// <param name="ch"></param> 593 /// <returns></returns> 594 public static String GetFirst(Char ch) 595 { 596 var rs = Get(ch); 597 if (!String.IsNullOrEmpty(rs)) rs = rs.Substring(0, 1); 598 599 return rs; 600 } 601 602 /// <summary> 603 /// 取拼音第一个字段 604 /// </summary> 605 /// <param name="str"></param> 606 /// <returns></returns> 607 public static String GetFirst(String str) 608 { 609 if (String.IsNullOrEmpty(str)) return String.Empty; 610 611 var sb = new StringBuilder(str.Length + 1); 612 var chs = str.ToCharArray(); 613 614 for (var i = 0; i < chs.Length; i++) 615 { 616 sb.Append(GetFirst(chs[i])); 617 } 618 619 return sb.ToString(); 620 } 621 622 /// <summary> 623 /// 获取单字拼音 624 /// </summary> 625 /// <param name="ch"></param> 626 /// <returns></returns> 627 public static String Get(Char ch) 628 { 629 // 拉丁字符 630 if (ch <= '\x00FF') return ch.ToString(); 631 632 // 标点符号、分隔符 633 if (Char.IsPunctuation(ch) || Char.IsSeparator(ch)) return ch.ToString(); 634 635 // 非中文字符 636 if (ch < '\x4E00' || ch > '\x9FA5') return ch.ToString(); 637 638 var arr = Encoding.GetEncoding("gb2312").GetBytes(ch.ToString()); 639 //Encoding.Default默认在中文环境里虽是GB2312,但在多变的环境可能是其它 640 //var arr = Encoding.Default.GetBytes(ch.ToString()); 641 var chr = (Int16)arr[0] * 256 + (Int16)arr[1] - 65536; 642 643 //***// 单字符--英文或半角字符 644 if (chr > 0 && chr < 160) return ch.ToString(); 645 #region 中文字符处理 646 647 // 判断是否超过GB2312-80标准中的汉字范围 648 if (chr > lastChCode || chr < firstChCode) 649 { 650 return ch.ToString();; 651 } 652 // 如果是在一级汉字中 653 else if (chr <= lastOfOneLevelChCode) 654 { 655 // 将一级汉字分为12块,每块33个汉字. 656 for (int aPos = 11; aPos >= 0; aPos--) 657 { 658 int aboutPos = aPos * 33; 659 // 从最后的块开始扫描,如果机内码大于块的第一个机内码,说明在此块中 660 if (chr >= pyValue[aboutPos]) 661 { 662 // Console.WriteLine("存在于第 " + aPos.ToString() + " 块,此块的第一个机内码是: " + pyValue[aPos * 33].ToString()); 663 // 遍历块中的每个音节机内码,从最后的音节机内码开始扫描, 664 // 如果音节内码小于机内码,则取此音节 665 for (int i = aboutPos + 32; i >= aboutPos; i--) 666 { 667 if (pyValue[i] <= chr) 668 { 669 // Console.WriteLine("找到第一个小于要查找机内码的机内码: " + pyValue[i].ToString()); 670 return pyName[i]; 671 } 672 } 673 break; 674 } 675 } 676 } 677 // 如果是在二级汉字中 678 else 679 { 680 int pos = Array.IndexOf(otherChinese, ch.ToString()); 681 if (pos != decimal.MinusOne) 682 { 683 return otherPinYin[pos]; 684 } 685 } 686 #endregion 中文字符处理 687 688 //if (chr < -20319 || chr > -10247) { // 不知道的字符 689 // return null; 690 691 //for (var i = pyValue.Length - 1; i >= 0; i--) 692 //{ 693 // if (pyValue[i] <= chr) return pyName[i];//这只能对应数组已经定义的 694 //} 695 696 return String.Empty; 697 } 698 699 /// <summary> 700 /// 把汉字转换成拼音(全拼) 701 /// </summary> 702 /// <param name="str">汉字字符串</param> 703 /// <returns>转换后的拼音(全拼)字符串</returns> 704 public static String GetPinYin(String str) 705 { 706 if (String.IsNullOrEmpty(str)) return String.Empty; 707 708 var sb = new StringBuilder(str.Length * 10); 709 var chs = str.ToCharArray(); 710 711 for (var j = 0; j < chs.Length; j++) 712 { 713 sb.Append(Get(chs[j])); 714 } 715 716 return sb.ToString(); 717 } 718 #endregionView Code
获取网页的HTML内容
1 #region 获取网页的HTML内容 2 // 获取网页的HTML内容,指定Encoding 3 public static string GetHtml(string url, Encoding encoding) 4 { 5 byte[] buf = new WebClient().DownloadData(url); 6 if (encoding != null) return encoding.GetString(buf); 7 string html = Encoding.UTF8.GetString(buf); 8 encoding = GetEncoding(html); 9 if (encoding == null || encoding == Encoding.UTF8) return html; 10 return encoding.GetString(buf); 11 } 12 // 根据网页的HTML内容提取网页的Encoding 13 public static Encoding GetEncoding(string html) 14 { 15 string pattern = @"(?i)\bcharset=(?<charset>[-a-zA-Z_0-9]+)"; 16 string charset = Regex.Match(html, pattern).Groups["charset"].Value; 17 try { return Encoding.GetEncoding(charset); } 18 catch (ArgumentException) { return null; } 19 } 20 #endregionView Code
我们引用的类库
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.IO; 6 using System.Net; 7 using System.Web; 8 using System.Security.Cryptography; 9 using System.Text.RegularExpressions; 10 using System.Web.Script.Serialization; 11 using System.Data; 12 using System.Collections; 13 using System.Runtime.Serialization.Json; 14 using System.Configuration; 15 using System.Reflection;View Code
完整的系统帮助类Utils
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.IO; 6 using System.Net; 7 using System.Web; 8 using System.Security.Cryptography; 9 using System.Text.RegularExpressions; 10 using System.Web.Script.Serialization; 11 using System.Data; 12 using System.Collections; 13 using System.Runtime.Serialization.Json; 14 using System.Configuration; 15 using System.Reflection; 16 17 namespace Common 18 { 19 /// <summary> 20 /// 系统帮助类 21 /// </summary> 22 public class Utils 23 { 24 #region 对象转换处理 25 /// <summary> 26 /// 判断对象是否为Int32类型的数字 27 /// </summary> 28 /// <param name="Expression"></param> 29 /// <returns></returns> 30 public static bool IsNumeric(object expression) 31 { 32 if (expression != null) 33 return IsNumeric(expression.ToString()); 34 35 return false; 36 37 } 38 39 /// <summary> 40 /// 判断对象是否为Int32类型的数字 41 /// </summary> 42 /// <param name="Expression"></param> 43 /// <returns></returns> 44 public static bool IsNumeric(string expression) 45 { 46 if (expression != null) 47 { 48 string str = expression; 49 if (str.Length > 0 && str.Length <= 11 && Regex.IsMatch(str, @"^[-]?[0-9]*[.]?[0-9]*$")) 50 { 51 if ((str.Length < 10) || (str.Length == 10 && str[0] == '1') || (str.Length == 11 && str[0] == '-' && str[1] == '1')) 52 return true; 53 } 54 } 55 return false; 56 } 57 58 /// <summary> 59 /// 是否为Double类型 60 /// </summary> 61 /// <param name="expression"></param> 62 /// <returns></returns> 63 public static bool IsDouble(object expression) 64 { 65 if (expression != null) 66 return Regex.IsMatch(expression.ToString(), @"^([0-9])[0-9]*(\.\w*)?$"); 67 68 return false; 69 } 70 71 /// <summary> 72 /// 将字符串转换为数组 73 /// </summary> 74 /// <param name="str">字符串</param> 75 /// <returns>字符串数组</returns> 76 public static string[] GetStrArray(string str) 77 { 78 return str.Split(new char[',']); 79 } 80 81 /// <summary> 82 /// 将数组转换为字符串 83 /// </summary> 84 /// <param name="list">List</param> 85 /// <param name="speater">分隔符</param> 86 /// <returns>String</returns> 87 public static string GetArrayStr(List<string> list, string speater) 88 { 89 StringBuilder sb = new StringBuilder(); 90 for (int i = 0; i < list.Count; i++) 91 { 92 if (i == list.Count - 1) 93 { 94 sb.Append(list[i]); 95 } 96 else 97 { 98 sb.Append(list[i]); 99 sb.Append(speater); 100 } 101 } 102 return sb.ToString(); 103 } 104 105 /// <summary> 106 /// object型转换为bool型 107 /// </summary> 108 /// <param name="strValue">要转换的字符串</param> 109 /// <param name="defValue">缺省值</param> 110 /// <returns>转换后的bool类型结果</returns> 111 public static bool StrToBool(object expression, bool defValue) 112 { 113 if (expression != null) 114 return StrToBool(expression, defValue); 115 116 return defValue; 117 } 118 119 /// <summary> 120 /// string型转换为bool型 121 /// </summary> 122 /// <param name="strValue">要转换的字符串</param> 123 /// <param name="defValue">缺省值</param> 124 /// <returns>转换后的bool类型结果</returns> 125 public static bool StrToBool(string expression, bool defValue) 126 { 127 if (expression != null) 128 { 129 if (string.Compare(expression, "true", true) == 0) 130 return true; 131 else if (string.Compare(expression, "false", true) == 0) 132 return false; 133 } 134 return defValue; 135 } 136 137 /// <summary> 138 /// 将对象转换为Int32类型 139 /// </summary> 140 /// <param name="expression">要转换的字符串</param> 141 /// <param name="defValue">缺省值</param> 142 /// <returns>转换后的int类型结果</returns> 143 public static int ObjToInt(object expression, int defValue) 144 { 145 if (expression != null) 146 return StrToInt(expression.ToString(), defValue); 147 148 return defValue; 149 } 150 151 /// <summary> 152 /// 将字符串转换为Int32类型 153 /// </summary> 154 /// <param name="expression">要转换的字符串</param> 155 /// <param name="defValue">缺省值</param> 156 /// <returns>转换后的int类型结果</returns> 157 public static int StrToInt(string expression, int defValue) 158 { 159 if (string.IsNullOrEmpty(expression) || expression.Trim().Length >= 11 || !Regex.IsMatch(expression.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$")) 160 return defValue; 161 162 int rv; 163 if (Int32.TryParse(expression, out rv)) 164 return rv; 165 166 return Convert.ToInt32(StrToFloat(expression, defValue)); 167 } 168 169 /// <summary> 170 /// Object型转换为decimal型 171 /// </summary> 172 /// <param name="strValue">要转换的字符串</param> 173 /// <param name="defValue">缺省值</param> 174 /// <returns>转换后的decimal类型结果</returns> 175 public static decimal ObjToDecimal(object expression, decimal defValue) 176 { 177 if (expression != null) 178 return StrToDecimal(expression.ToString(), defValue); 179 180 return defValue; 181 } 182 183 /// <summary> 184 /// string型转换为decimal型 185 /// </summary> 186 /// <param name="strValue">要转换的字符串</param> 187 /// <param name="defValue">缺省值</param> 188 /// <returns>转换后的decimal类型结果</returns> 189 public static decimal StrToDecimal(string expression, decimal defValue) 190 { 191 if ((expression == null) || (expression.Length > 10)) 192 return defValue; 193 194 decimal intValue = defValue; 195 if (expression != null) 196 { 197 bool IsDecimal = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$"); 198 if (IsDecimal) 199 decimal.TryParse(expression, out intValue); 200 } 201 return intValue; 202 } 203 204 /// <summary> 205 /// Object型转换为float型 206 /// </summary> 207 /// <param name="strValue">要转换的字符串</param> 208 /// <param name="defValue">缺省值</param> 209 /// <returns>转换后的int类型结果</returns> 210 public static float ObjToFloat(object expression, float defValue) 211 { 212 if (expression != null) 213 return StrToFloat(expression.ToString(), defValue); 214 215 return defValue; 216 } 217 218 /// <summary> 219 /// string型转换为float型 220 /// </summary> 221 /// <param name="strValue">要转换的字符串</param> 222 /// <param name="defValue">缺省值</param> 223 /// <returns>转换后的int类型结果</returns> 224 public static float StrToFloat(string expression, float defValue) 225 { 226 if ((expression == null) || (expression.Length > 10)) 227 return defValue; 228 229 float intValue = defValue; 230 if (expression != null) 231 { 232 bool IsFloat = Regex.IsMatch(expression, @"^([-]|[0-9])[0-9]*(\.\w*)?$"); 233 if (IsFloat) 234 float.TryParse(expression, out intValue); 235 } 236 return intValue; 237 } 238 239 /// <summary> 240 /// 将对象转换为日期时间类型 241 /// </summary> 242 /// <param name="str">要转换的字符串</param> 243 /// <param name="defValue">缺省值</param> 244 /// <returns>转换后的int类型结果</returns> 245 public static DateTime StrToDateTime(string str, DateTime defValue) 246 { 247 if (!string.IsNullOrEmpty(str)) 248 { 249 DateTime dateTime; 250 if (DateTime.TryParse(str, out dateTime)) 251 return dateTime; 252 } 253 return defValue; 254 } 255 256 /// <summary> 257 /// 将对象转换为日期时间类型 258 /// </summary> 259 /// <param name="str">要转换的字符串</param> 260 /// <returns>转换后的int类型结果</returns> 261 public static DateTime StrToDateTime(string str) 262 { 263 return StrToDateTime(str, DateTime.Now); 264 } 265 266 /// <summary> 267 /// 将对象转换为日期时间类型 268 /// </summary> 269 /// <param name="obj">要转换的对象</param> 270 /// <returns>转换后的int类型结果</returns> 271 public static DateTime ObjectToDateTime(object obj) 272 { 273 return StrToDateTime(obj.ToString()); 274 } 275 276 /// <summary> 277 /// 将对象转换为日期时间类型 278 /// </summary> 279 /// <param name="obj">要转换的对象</param> 280 /// <param name="defValue">缺省值</param> 281 /// <returns>转换后的int类型结果</returns> 282 public static DateTime ObjectToDateTime(object obj, DateTime defValue) 283 { 284 return StrToDateTime(obj.ToString(), defValue); 285 } 286 287 /// <summary> 288 /// 将对象转换为字符串 289 /// </summary> 290 /// <param name="obj">要转换的对象</param> 291 /// <returns>转换后的string类型结果</returns> 292 public static string ObjectToStr(object obj) 293 { 294 if (obj == null) 295 return ""; 296 return obj.ToString().Trim(); 297 } 298 #endregion 299 300 #region 分割字符串 301 /// <summary> 302 /// 分割字符串 303 /// </summary> 304 public static string[] SplitString(string strContent, string strSplit) 305 { 306 if (!string.IsNullOrEmpty(strContent)) 307 { 308 if (strContent.IndexOf(strSplit) < 0) 309 return new string[] { strContent }; 310 311 return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase); 312 } 313 else 314 return new string[0] { }; 315 } 316 317 /// <summary> 318 /// 分割字符串 319 /// </summary> 320 /// <returns></returns> 321 public static string[] SplitString(string strContent, string strSplit, int count) 322 { 323 string[] result = new string[count]; 324 string[] splited = SplitString(strContent, strSplit); 325 326 for (int i = 0; i < count; i++) 327 { 328 if (i < splited.Length) 329 result[i] = splited[i]; 330 else 331 result[i] = string.Empty; 332 } 333 334 return result; 335 } 336 #endregion 337 338 #region 截取字符串 339 public static string GetSubString(string p_SrcString, int p_Length, string p_TailString) 340 { 341 return GetSubString(p_SrcString, 0, p_Length, p_TailString); 342 } 343 public static string GetSubString(string p_SrcString, int p_StartIndex, int p_Length, string p_TailString) 344 { 345 string str = p_SrcString; 346 byte[] bytes = Encoding.UTF8.GetBytes(p_SrcString); 347 foreach (char ch in Encoding.UTF8.GetChars(bytes)) 348 { 349 if (((ch > '?') && (ch < '一')) || ((ch > 0xac00) && (ch < 0xd7a3))) 350 { 351 if (p_StartIndex >= p_SrcString.Length) 352 { 353 return ""; 354 } 355 return p_SrcString.Substring(p_StartIndex, ((p_Length + p_StartIndex) > p_SrcString.Length) ? (p_SrcString.Length - p_StartIndex) : p_Length); 356 } 357 } 358 if (p_Length < 0) 359 { 360 return str; 361 } 362 byte[] sourceArray = Encoding.Default.GetBytes(p_SrcString); 363 if (sourceArray.Length <= p_StartIndex) 364 { 365 return str; 366 } 367 int length = sourceArray.Length; 368 if (sourceArray.Length > (p_StartIndex + p_Length)) 369 { 370 length = p_Length + p_StartIndex; 371 } 372 else 373 { 374 p_Length = sourceArray.Length - p_StartIndex; 375 p_TailString = ""; 376 } 377 int num2 = p_Length; 378 int[] numArray = new int[p_Length]; 379 byte[] destinationArray = null; 380 int num3 = 0; 381 for (int i = p_StartIndex; i < length; i++) 382 { 383 if (sourceArray[i] > 0x7f) 384 { 385 num3++; 386 if (num3 == 3) 387 { 388 num3 = 1; 389 } 390 } 391 else 392 { 393 num3 = 0; 394 } 395 numArray[i] = num3; 396 } 397 if ((sourceArray[length - 1] > 0x7f) && (numArray[p_Length - 1] == 1)) 398 { 399 num2 = p_Length + 1; 400 } 401 destinationArray = new byte[num2]; 402 Array.Copy(sourceArray, p_StartIndex, destinationArray, 0, num2); 403 return (Encoding.Default.GetString(destinationArray) + p_TailString); 404 } 405 #endregion 406 407 #region 删除最后结尾的一个逗号 408 /// <summary> 409 /// 删除最后结尾的一个逗号 410 /// </summary> 411 public static string DelLastComma(string str) 412 { 413 return str.Substring(0, str.LastIndexOf(",")); 414 } 415 #endregion 416 417 #region 删除最后结尾的指定字符后的字符 418 /// <summary> 419 /// 删除最后结尾的指定字符后的字符 420 /// </summary> 421 public static string DelLastChar(string str, string strchar) 422 { 423 if (string.IsNullOrEmpty(str)) 424 return ""; 425 if (str.LastIndexOf(strchar) >= 0 && str.LastIndexOf(strchar) == str.Length - 1) 426 { 427 return str.Substring(0, str.LastIndexOf(strchar)); 428 } 429 return str; 430 } 431 #endregion 432 433 #region 生成指定长度的字符串 434 /// <summary> 435 /// 生成指定长度的字符串,即生成strLong个str字符串 436 /// </summary> 437 /// <param name="strLong">生成的长度</param> 438 /// <param name="str">以str生成字符串</param> 439 /// <returns></returns> 440 public static string StringOfChar(int strLong, string str) 441 { 442 string ReturnStr = ""; 443 for (int i = 0; i < strLong; i++) 444 { 445 ReturnStr += str; 446 } 447 448 return ReturnStr; 449 } 450 #endregion 451 452 #region 生成日期随机码 453 /// <summary> 454 /// 生成日期随机码 455 /// </summary> 456 /// <returns></returns> 457 public static string GetRamCode() 458 { 459 #region 460 return DateTime.Now.ToString("yyyyMMddHHmmssffff"); 461 #endregion 462 } 463 #endregion 464 465 #region 生成随机字母或数字 466 /// <summary> 467 /// 生成随机数字 468 /// </summary> 469 /// <param name="length">生成长度</param> 470 /// <returns></returns> 471 public static string Number(int Length) 472 { 473 return Number(Length, false); 474 } 475 476 /// <summary> 477 /// 生成随机数字 478 /// </summary> 479 /// <param name="Length">生成长度</param> 480 /// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param> 481 /// <returns></returns> 482 public static string Number(int Length, bool Sleep) 483 { 484 if (Sleep) 485 System.Threading.Thread.Sleep(3); 486 string result = ""; 487 System.Random random = new Random(); 488 for (int i = 0; i < Length; i++) 489 { 490 result += random.Next(10).ToString(); 491 } 492 return result; 493 } 494 /// <summary> 495 /// 生成随机字母字符串(数字字母混和) 496 /// </summary> 497 /// <param name="codeCount">待生成的位数</param> 498 public static string GetCheckCode(int codeCount) 499 { 500 string str = string.Empty; 501 int rep = 0; 502 long num2 = DateTime.Now.Ticks + rep; 503 rep++; 504 Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> rep))); 505 for (int i = 0; i < codeCount; i++) 506 { 507 char ch; 508 int num = random.Next(); 509 if ((num % 2) == 0) 510 { 511 ch = (char)(0x30 + ((ushort)(num % 10))); 512 } 513 else 514 { 515 ch = (char)(0x41 + ((ushort)(num % 0x1a))); 516 } 517 str = str + ch.ToString(); 518 } 519 return str; 520 } 521 /// <summary> 522 /// 根据日期和随机码生成订单号 523 /// </summary> 524 /// <returns></returns> 525 public static string GetOrderNumber() 526 { 527 string num = DateTime.Now.ToString("yyMMddHHmmss");//yyyyMMddHHmmssms 528 return num + Number(2).ToString(); 529 } 530 private static int Next(int numSeeds, int length) 531 { 532 byte[] buffer = new byte[length]; 533 System.Security.Cryptography.RNGCryptoServiceProvider Gen = new System.Security.Cryptography.RNGCryptoServiceProvider(); 534 Gen.GetBytes(buffer); 535 uint randomResult = 0x0;//这里用uint作为生成的随机数 536 for (int i = 0; i < length; i++) 537 { 538 randomResult |= ((uint)buffer[i] << ((length - 1 - i) * 8)); 539 } 540 return (int)(randomResult % numSeeds); 541 } 542 #endregion 543 544 #region 截取字符长度 545 /// <summary> 546 /// 截取字符长度 547 /// </summary> 548 /// <param name="inputString">字符</param> 549 /// <param name="len">长度</param> 550 /// <returns></returns> 551 public static string CutString(string inputString, int len) 552 { 553 if (string.IsNullOrEmpty(inputString)) 554 return ""; 555 inputString = DropHTML(inputString); 556 ASCIIEncoding ascii = new ASCIIEncoding(); 557 int tempLen = 0; 558 string tempString = ""; 559 byte[] s = ascii.GetBytes(inputString); 560 for (int i = 0; i < s.Length; i++) 561 { 562 if ((int)s[i] == 63) 563 { 564 tempLen += 2; 565 } 566 else 567 { 568 tempLen += 1; 569 } 570 571 try 572 { 573 tempString += inputString.Substring(i, 1); 574 } 575 catch 576 { 577 break; 578 } 579 580 if (tempLen > len) 581 break; 582 } 583 //如果截过则加上半个省略号 584 byte[] mybyte = System.Text.Encoding.Default.GetBytes(inputString); 585 if (mybyte.Length > len) 586 tempString += "…"; 587 return tempString; 588 } 589 #endregion 590 591 #region 对象<-->JSON 4.0使用 592 /// <summary> 593 /// 对象转JSON 594 /// </summary> 595 /// <typeparam name="T">对象实体</typeparam> 596 /// <param name="t">内容</param> 597 /// <returns>json包</returns> 598 public static string ObjetcToJson<T>(T t) 599 { 600 try 601 { 602 DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(T)); 603 string szJson = ""; 604 using (MemoryStream stream = new MemoryStream()) 605 { 606 json.WriteObject(stream, t); 607 szJson = Encoding.UTF8.GetString(stream.ToArray()); 608 } 609 return szJson; 610 } 611 catch { return ""; } 612 } 613 614 /// <summary> 615 /// Json包转对象 616 /// </summary> 617 /// <typeparam name="T">对象</typeparam> 618 /// <param name="jsonstring">json包</param> 619 /// <returns>异常抛null</returns> 620 public static object JsonToObject<T>(string jsonstring) 621 { 622 object result = null; 623 try 624 { 625 DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(T)); 626 using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonstring))) 627 { 628 result = json.ReadObject(stream); 629 } 630 return result; 631 } 632 catch { return result; } 633 } 634 #endregion 635 636 #region 对象<-->JSON 2.0 使用litjson插件 637 /// <summary> 638 /// 对象转JSON jsonData 639 /// </summary> 640 /// <typeparam name="T"></typeparam> 641 /// <param name="t"></param> 642 /// <returns></returns> 643 //public static string ObjetcToJsonData<T>(T t) 644 //{ 645 // try 646 // { 647 // JsonData json = new JsonData(t); 648 // return json.ToJson(); 649 // } 650 // catch 651 // { 652 // return ""; 653 // } 654 //} 655 656 ///// <summary> 657 ///// 对象转JSON jsonMapper 658 ///// </summary> 659 ///// <typeparam name="T"></typeparam> 660 ///// <param name="t"></param> 661 ///// <returns></returns> 662 //public static string ObjetcToJsonMapper<T>(T t) 663 //{ 664 // try 665 // { 666 // JsonData json = JsonMapper.ToJson(t); 667 // return json.ToJson(); 668 // } 669 // catch 670 // { 671 // return ""; 672 // } 673 //} 674 675 ///// <summary> 676 ///// json转对象 jsonMapper 677 ///// </summary> 678 ///// <param name="jsons"></param> 679 ///// <returns></returns> 680 //public static object JsonToObject(string jsons) 681 //{ 682 // try 683 // { 684 // JsonData jsonObject = JsonMapper.ToObject(jsons); 685 // return jsonObject; 686 // } 687 // catch { return null; } 688 //} 689 690 #endregion 691 692 #region DataTable<-->JSON 693 /// <summary> 694 /// DataTable转为json 695 /// </summary> 696 /// <param name="dt">DataTable</param> 697 /// <returns>json数据</returns> 698 public static string DataTableToJson(DataTable dt) 699 { 700 List<Dictionary<string, object>> list = new List<Dictionary<string, object>>(); 701 foreach (DataRow dr in dt.Rows) 702 { 703 Dictionary<string, object> result = new Dictionary<string, object>(); 704 foreach (DataColumn dc in dt.Columns) 705 { 706 result.Add(dc.ColumnName, dr[dc]); 707 } 708 list.Add(result); 709 } 710 711 return SerializeToJson(list); 712 } 713 /// <summary> 714 /// 序列化对象为Json字符串 715 /// </summary> 716 /// <param name="obj">要序列化的对象</param> 717 /// <param name="recursionLimit">序列化对象的深度,默认为100</param> 718 /// <returns>Json字符串</returns> 719 public static string SerializeToJson(object obj, int recursionLimit = 100) 720 { 721 try 722 { 723 JavaScriptSerializer serialize = new JavaScriptSerializer(); 724 serialize.RecursionLimit = recursionLimit; 725 return serialize.Serialize(obj); 726 } 727 catch { return ""; } 728 } 729 /// <summary> 730 /// json包转DataTable 731 /// </summary> 732 /// <param name="jsons"></param> 733 /// <returns></returns> 734 public static DataTable JsonToDataTable(string jsons) 735 { 736 DataTable dt = new DataTable(); 737 try 738 { 739 JavaScriptSerializer serialize = new JavaScriptSerializer(); 740 serialize.MaxJsonLength = Int32.MaxValue; 741 ArrayList list = serialize.Deserialize<ArrayList>(jsons); 742 if (list.Count > 0) 743 { 744 foreach (Dictionary<string, object> item in list) 745 { 746 if (item.Keys.Count == 0)//无值返回空 747 { 748 return dt; 749 } 750 if (dt.Columns.Count == 0)//初始Columns 751 { 752 foreach (string current in item.Keys) 753 { 754 dt.Columns.Add(current, item[current].GetType()); 755 } 756 } 757 DataRow dr = dt.NewRow(); 758 foreach (string current in item.Keys) 759 { 760 dr[current] = item[current]; 761 } 762 dt.Rows.Add(dr); 763 } 764 } 765 } 766 catch 767 { 768 return dt; 769 } 770 return dt; 771 } 772 #endregion 773 774 #region List<--->DataTable 775 /// <summary> 776 /// DataTable转换泛型集合 777 /// </summary> 778 /// <typeparam name="T"></typeparam> 779 /// <param name="table"></param> 780 /// <returns></returns> 781 public static List<T> DataTableToList<T>(DataTable table) 782 { 783 List<T> list = new List<T>(); 784 T t = default(T); 785 PropertyInfo[] propertypes = null; 786 string tempName = string.Empty; 787 foreach (DataRow row in table.Rows) 788 { 789 t = Activator.CreateInstance<T>(); 790 propertypes = t.GetType().GetProperties(); 791 foreach (PropertyInfo pro in propertypes) 792 { 793 tempName = pro.Name; 794 if (table.Columns.Contains(tempName)) 795 { 796 object value = row[tempName]; 797 if (!value.ToString().Equals("")) 798 { 799 pro.SetValue(t, value, null); 800 } 801 } 802 } 803 list.Add(t); 804 } 805 return list.Count == 0 ? null : list; 806 } 807 808 /// <summary> 809 /// 将集合类转换成DataTable 810 /// </summary> 811 /// <param name="list">集合</param> 812 /// <returns>DataTable</returns> 813 public static DataTable ListToDataTable(IList list) 814 { 815 DataTable result = new DataTable(); 816 if (list != null && list.Count > 0) 817 { 818 PropertyInfo[] propertys = list[0].GetType().GetProperties(); 819 foreach (PropertyInfo pi in propertys) 820 { 821 result.Columns.Add(pi.Name, pi.PropertyType); 822 } 823 for (int i = 0; i < list.Count; i++) 824 { 825 ArrayList tempList = new ArrayList(); 826 foreach (PropertyInfo pi in propertys) 827 { 828 object obj = pi.GetValue(list[i], null); 829 tempList.Add(obj); 830 } 831 object[] array = tempList.ToArray(); 832 result.LoadDataRow(array, true); 833 } 834 } 835 return result; 836 } 837 public static List<T> ConvertTo<T>(DataTable dt) where T : new() 838 { 839 if (dt == null) return null; 840 if (dt.Rows.Count <= 0) return null; 841 842 List<T> list = new List<T>(); 843 try 844 { 845 List<string> columnsName = new List<string>(); 846 foreach (DataColumn dataColumn in dt.Columns) 847 { 848 columnsName.Add(dataColumn.ColumnName);//得到所有的表头 849 } 850 list = dt.AsEnumerable().ToList().ConvertAll<T>(row => GetObject<T>(row, columnsName)); //转换 851 return list; 852 } 853 catch 854 { 855 return null; 856 } 857 } 858 859 public static T GetObject<T>(DataRow row, List<string> columnsName) where T : new() 860 { 861 T obj = new T(); 862 try 863 { 864 string columnname = ""; 865 string value = ""; 866 PropertyInfo[] Properties = typeof(T).GetProperties(); 867 foreach (PropertyInfo objProperty in Properties) //遍历T的属性 868 { 869 columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower()); //寻找可以匹配的表头名称 870 if (!string.IsNullOrEmpty(columnname)) 871 { 872 value = row[columnname].ToString(); 873 if (!string.IsNullOrEmpty(value)) 874 { 875 if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null) //存在匹配的表头 876 { 877 value = row[columnname].ToString().Replace("$", "").Replace(",", ""); //从dataRow中提取数据 878 objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())), null); //赋值操作 879 } 880 else 881 { 882 value = row[columnname].ToString().Replace("%", ""); //存在匹配的表头 883 objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);//赋值操作 884 } 885 } 886 } 887 } 888 return obj; 889 } 890 catch 891 { 892 return obj; 893 } 894 } 895 /// <summary> 896 /// 将泛型集合类转换成DataTable 897 /// </summary> 898 /// <typeparam name="T">集合项类型</typeparam> 899 /// <param name="list">集合</param> 900 /// <param name="propertyName">需要返回的列的列名</param> 901 /// <returns>数据集(表)</returns> 902 public static DataTable ListToDataTable<T>(IList<T> list, params string[] propertyName) 903 { 904 List<string> propertyNameList = new List<string>(); 905 if (propertyName != null) 906 propertyNameList.AddRange(propertyName); 907 DataTable result = new DataTable(); 908 if (list != null && list.Count > 0) 909 { 910 PropertyInfo[] propertys = list[0].GetType().GetProperties(); 911 foreach (PropertyInfo pi in propertys) 912 { 913 if (propertyNameList.Count == 0) 914 { 915 result.Columns.Add(pi.Name, pi.PropertyType); 916 } 917 else 918 { 919 if (propertyNameList.Contains(pi.Name)) 920 result.Columns.Add(pi.Name, pi.PropertyType); 921 } 922 } 923 for (int i = 0; i < list.Count; i++) 924 { 925 ArrayList tempList = new ArrayList(); 926 foreach (PropertyInfo pi in propertys) 927 { 928 if (propertyNameList.Count == 0) 929 { 930 object obj = pi.GetValue(list[i], null); 931 tempList.Add(obj); 932 } 933 else 934 { 935 if (propertyNameList.Contains(pi.Name)) 936 { 937 object obj = pi.GetValue(list[i], null); 938 tempList.Add(obj); 939 } 940 } 941 } 942 object[] array = tempList.ToArray(); 943 result.LoadDataRow(array, true); 944 } 945 } 946 return result; 947 } 948 949 #endregion 950 951 #region 清除HTML标记 952 public static string DropHTML(string Htmlstring) 953 { 954 if (string.IsNullOrEmpty(Htmlstring)) return ""; 955 //删除脚本 956 Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); 957 //删除HTML 958 Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); 959 Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase); 960 Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase); 961 Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase); 962 Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase); 963 Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase); 964 Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase); 965 Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase); 966 Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase); 967 Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase); 968 Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase); 969 Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase); 970 Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase); 971 972 Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase); 973 Htmlstring.Replace("<", ""); 974 Htmlstring.Replace(">", ""); 975 Htmlstring.Replace("\r\n", ""); 976 Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim(); 977 return Htmlstring; 978 } 979 #endregion 980 981 #region 清除HTML标记且返回相应的长度 982 public static string DropHTML(string Htmlstring, int strLen) 983 { 984 return CutString(DropHTML(Htmlstring), strLen); 985 } 986 #endregion 987 988 #region TXT代码转换成HTML格式 989 /// <summary> 990 /// 字符串字符处理 991 /// </summary> 992 /// <param name="chr">等待处理的字符串</param> 993 /// <returns>处理后的字符串</returns> 994 /// //把TXT代码转换成HTML格式 995 public static String ToHtml(string Input) 996 { 997 StringBuilder sb = new StringBuilder(Input); 998 sb.Replace("&", "&"); 999 sb.Replace("<", "<"); 1000 sb.Replace(">", ">"); 1001 sb.Replace("\r\n", "<br />"); 1002 sb.Replace("\n", "<br />"); 1003 sb.Replace("\t", " "); 1004 //sb.Replace(" ", " "); 1005 return sb.ToString(); 1006 } 1007 #endregion 1008 1009 #region HTML代码转换成TXT格式 1010 /// <summary> 1011 /// 字符串字符处理 1012 /// </summary> 1013 /// <param name="chr">等待处理的字符串</param> 1014 /// <returns>处理后的字符串</returns> 1015 /// //把HTML代码转换成TXT格式 1016 public static String ToTxt(String Input) 1017 { 1018 StringBuilder sb = new StringBuilder(Input); 1019 sb.Replace(" ", " "); 1020 sb.Replace("<br>", "\r\n"); 1021 sb.Replace("<br>", "\n"); 1022 sb.Replace("<br />", "\n"); 1023 sb.Replace("<br />", "\r\n"); 1024 sb.Replace("<", "<"); 1025 sb.Replace(">", ">"); 1026 sb.Replace("&", "&"); 1027 return sb.ToString(); 1028 } 1029 #endregion 1030 1031 #region 检测是否有Sql危险字符 1032 /// <summary> 1033 /// 检测是否有Sql危险字符 1034 /// </summary> 1035 /// <param name="str">要判断字符串</param> 1036 /// <returns>判断结果</returns> 1037 public static bool IsSafeSqlString(string str) 1038 { 1039 return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']"); 1040 } 1041 1042 /// <summary> 1043 /// 检查危险字符 1044 /// </summary> 1045 /// <param name="Input"></param> 1046 /// <returns></returns> 1047 public static string Filter(string sInput) 1048 { 1049 if (sInput == null || sInput == "") 1050 return null; 1051 string sInput1 = sInput.ToLower(); 1052 string output = sInput; 1053 string pattern = @"*|and|exec|insert|select|delete|update|count|master|truncate|declare|char(|mid(|chr(|'"; 1054 if (Regex.Match(sInput1, Regex.Escape(pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase).Success) 1055 { 1056 throw new Exception("字符串中含有非法字符!"); 1057 } 1058 else 1059 { 1060 output = output.Replace("'", "''"); 1061 } 1062 return output; 1063 } 1064 1065 /// <summary> 1066 /// 检查过滤设定的危险字符 1067 /// </summary> 1068 /// <param name="InText">要过滤的字符串 </param> 1069 /// <returns>如果参数存在不安全字符,则返回true </returns> 1070 public static bool SqlFilter(string word, string InText) 1071 { 1072 if (InText == null) 1073 return false; 1074 foreach (string i in word.Split('|')) 1075 { 1076 if ((InText.ToLower().IndexOf(i + " ") > -1) || (InText.ToLower().IndexOf(" " + i) > -1)) 1077 { 1078 return true; 1079 } 1080 } 1081 return false; 1082 } 1083 #endregion 1084 1085 #region 过滤特殊字符 1086 /// <summary> 1087 /// 过滤特殊字符 1088 /// </summary> 1089 /// <param name="Input"></param> 1090 /// <returns></returns> 1091 public static string Htmls(string Input) 1092 { 1093 if (Input != string.Empty && Input != null) 1094 { 1095 string ihtml = Input.ToLower(); 1096 ihtml = ihtml.Replace("<script", "<script"); 1097 ihtml = ihtml.Replace("script>", "script>"); 1098 ihtml = ihtml.Replace("<%", "<%"); 1099 ihtml = ihtml.Replace("%>", "%>"); 1100 ihtml = ihtml.Replace("<$", "<$"); 1101 ihtml = ihtml.Replace("$>", "$>"); 1102 return ihtml; 1103 } 1104 else 1105 { 1106 return string.Empty; 1107 } 1108 } 1109 #endregion 1110 1111 #region 检查是否为IP地址 1112 /// <summary> 1113 /// 是否为ip 1114 /// </summary> 1115 /// <param name="ip"></param> 1116 /// <returns></returns> 1117 public static bool IsIP(string ip) 1118 { 1119 return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"); 1120 } 1121 #endregion 1122 1123 #region 获得配置文件节点XML文件的绝对路径 1124 public static string GetXmlMapPath(string xmlName) 1125 { 1126 return GetMapPath(ConfigurationManager.AppSettings[xmlName].ToString()); 1127 } 1128 #endregion 1129 1130 #region 获得当前绝对路径 1131 /// <summary> 1132 /// 获得当前绝对路径 1133 /// </summary> 1134 /// <param name="strPath">指定的路径</param> 1135 /// <returns>绝对路径</returns> 1136 public static string GetMapPath(string strPath) 1137 { 1138 if (strPath.ToLower().StartsWith("http://")) 1139 { 1140 return strPath; 1141 } 1142 if (HttpContext.Current != null) 1143 { 1144 return HttpContext.Current.Server.MapPath(strPath); 1145 } 1146 else //非web程序引用 1147 { 1148 strPath = strPath.Replace("/", "\\"); 1149 if (strPath.StartsWith("\\")) 1150 { 1151 strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\'); 1152 } 1153 return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath); 1154 } 1155 } 1156 #endregion 1157 1158 #region 文件操作 1159 /// <summary> 1160 /// 删除单个文件 1161 /// </summary> 1162 /// <param name="_filepath">文件相对路径</param> 1163 public static bool DeleteFile(string _filepath) 1164 { 1165 if (string.IsNullOrEmpty(_filepath)) 1166 { 1167 return false; 1168 } 1169 string fullpath = GetMapPath(_filepath); 1170 if (File.Exists(fullpath)) 1171 { 1172 File.Delete(fullpath); 1173 return true; 1174 } 1175 return false; 1176 } 1177 1178 /// <summary> 1179 /// 删除上传的文件(及缩略图) 1180 /// </summary> 1181 /// <param name="_filepath"></param> 1182 public static void DeleteUpFile(string _filepath) 1183 { 1184 if (string.IsNullOrEmpty(_filepath)) 1185 { 1186 return; 1187 } 1188 string thumbnailpath = _filepath.Substring(0, _filepath.LastIndexOf("/")) + "mall_" + _filepath.Substring(_filepath.LastIndexOf("/") + 1); 1189 string fullTPATH = GetMapPath(_filepath); //宿略图 1190 string fullpath = GetMapPath(_filepath); //原图 1191 if (File.Exists(fullpath)) 1192 { 1193 File.Delete(fullpath); 1194 } 1195 if (File.Exists(fullTPATH)) 1196 { 1197 File.Delete(fullTPATH); 1198 } 1199 } 1200 1201 /// <summary> 1202 /// 返回文件大小KB 1203 /// </summary> 1204 /// <param name="_filepath">文件相对路径</param> 1205 /// <returns>int</returns> 1206 public static int GetFileSize(string _filepath) 1207 { 1208 if (string.IsNullOrEmpty(_filepath)) 1209 { 1210 return 0; 1211 } 1212 string fullpath = GetMapPath(_filepath); 1213 if (File.Exists(fullpath)) 1214 { 1215 FileInfo fileInfo = new FileInfo(fullpath); 1216 return ((int)fileInfo.Length) / 1024; 1217 } 1218 return 0; 1219 } 1220 1221 /// <summary> 1222 /// 返回文件扩展名,不含“.” 1223 /// </summary> 1224 /// <param name="_filepath">文件全名称</param> 1225 /// <returns>string</returns> 1226 public static string GetFileExt(string _filepath) 1227 { 1228 if (string.IsNullOrEmpty(_filepath)) 1229 { 1230 return ""; 1231 } 1232 if (_filepath.LastIndexOf(".") > 0) 1233 { 1234 return _filepath.Substring(_filepath.LastIndexOf(".") + 1); //文件扩展名,不含“.” 1235 } 1236 return ""; 1237 } 1238 1239 /// <summary> 1240 /// 返回文件名,不含路径 1241 /// </summary> 1242 /// <param name="_filepath">文件相对路径</param> 1243 /// <returns>string</returns> 1244 public static string GetFileName(string _filepath) 1245 { 1246 return _filepath.Substring(_filepath.LastIndexOf(@"/") + 1); 1247 } 1248 1249 /// <summary> 1250 /// 文件是否存在 1251 /// </summary> 1252 /// <param name="_filepath">文件相对路径</param> 1253 /// <returns>bool</returns> 1254 public static bool FileExists(string _filepath) 1255 { 1256 string fullpath = GetMapPath(_filepath); 1257 if (File.Exists(fullpath)) 1258 { 1259 return true; 1260 } 1261 return false; 1262 } 1263 1264 /// <summary> 1265 /// 获得远程字符串 1266 /// </summary> 1267 public static string GetDomainStr(string key, string uriPath) 1268 { 1269 string result = string.Empty;// CacheHelper.Get(key) as string; 1270 if (result == null) 1271 { 1272 System.Net.WebClient client = new System.Net.WebClient(); 1273 try 1274 { 1275 client.Encoding = System.Text.Encoding.UTF8; 1276 result = client.DownloadString(uriPath); 1277 } 1278 catch 1279 { 1280 result = "暂时无法连接!"; 1281 } 1282 //CacheHelper.Insert(key, result, 60); 1283 } 1284 1285 return result; 1286 } 1287 /// <summary> 1288 /// 读取指定文件中的内容,文件名为空或找不到文件返回空串 1289 /// </summary> 1290 /// <param name="FileName">文件全路径</param> 1291 /// <param name="isLineWay">是否按行读取返回字符串 true为是</param> 1292 public static string GetFileContent(string FileName, bool isLineWay) 1293 { 1294 string result = string.Empty; 1295 using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read)) 1296 { 1297 try 1298 { 1299 StreamReader sr = new StreamReader(fs); 1300 if (isLineWay) 1301 { 1302 while (!sr.EndOfStream) 1303 { 1304 result += sr.ReadLine() + "\n"; 1305 } 1306 } 1307 else 1308 { 1309 result = sr.ReadToEnd(); 1310 } 1311 sr.Close(); 1312 fs.Close(); 1313 } 1314 catch (Exception ee) 1315 { 1316 throw ee; 1317 } 1318 } 1319 return result; 1320 } 1321 #endregion 1322 1323 #region 读取或写入cookie 1324 /// <summary> 1325 /// 写cookie值 1326 /// </summary> 1327 /// <param name="strName">名称</param> 1328 /// <param name="strValue">值</param> 1329 public static void WriteCookie(string strName, string strValue) 1330 { 1331 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 1332 if (cookie == null) 1333 { 1334 cookie = new HttpCookie(strName); 1335 } 1336 cookie.Value = UrlEncode(strValue); 1337 HttpContext.Current.Response.AppendCookie(cookie); 1338 } 1339 1340 /// <summary> 1341 /// 写cookie值 1342 /// </summary> 1343 /// <param name="strName">名称</param> 1344 /// <param name="strValue">值</param> 1345 public static void WriteCookie(string strName, string key, string strValue) 1346 { 1347 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 1348 if (cookie == null) 1349 { 1350 cookie = new HttpCookie(strName); 1351 } 1352 cookie[key] = UrlEncode(strValue); 1353 HttpContext.Current.Response.AppendCookie(cookie); 1354 } 1355 1356 /// <summary> 1357 /// 写cookie值 1358 /// </summary> 1359 /// <param name="strName">名称</param> 1360 /// <param name="strValue">值</param> 1361 public static void WriteCookie(string strName, string key, string strValue, int expires) 1362 { 1363 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 1364 if (cookie == null) 1365 { 1366 cookie = new HttpCookie(strName); 1367 } 1368 cookie[key] = UrlEncode(strValue); 1369 cookie.Expires = DateTime.Now.AddMinutes(expires); 1370 HttpContext.Current.Response.AppendCookie(cookie); 1371 } 1372 1373 /// <summary> 1374 /// 写cookie值 1375 /// </summary> 1376 /// <param name="strName">名称</param> 1377 /// <param name="strValue">值</param> 1378 /// <param name="strValue">过期时间(分钟)</param> 1379 public static void WriteCookie(string strName, string strValue, int expires) 1380 { 1381 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 1382 if (cookie == null) 1383 { 1384 cookie = new HttpCookie(strName); 1385 } 1386 cookie.Value = UrlEncode(strValue); 1387 cookie.Expires = DateTime.Now.AddMinutes(expires); 1388 HttpContext.Current.Response.AppendCookie(cookie); 1389 } 1390 /// <summary> 1391 /// 写cookie值 1392 /// </summary> 1393 /// <param name="strName">名称</param> 1394 /// <param name="expires">过期时间(天)</param> 1395 public static void WriteCookie(string strName, int expires) 1396 { 1397 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 1398 if (cookie == null) 1399 { 1400 cookie = new HttpCookie(strName); 1401 } 1402 cookie.Expires = DateTime.Now.AddDays(expires); 1403 HttpContext.Current.Response.AppendCookie(cookie); 1404 } 1405 1406 /// <summary> 1407 /// 写入COOKIE,并指定过期时间 1408 /// </summary> 1409 /// <param name="strName">KEY</param> 1410 /// <param name="strValue">VALUE</param> 1411 /// <param name="expires">过期时间</param> 1412 public static void iWriteCookie(string strName, string strValue, int expires) 1413 { 1414 HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; 1415 if (cookie == null) 1416 { 1417 cookie = new HttpCookie(strName); 1418 } 1419 cookie.Value = strValue; 1420 if (expires > 0) 1421 { 1422 cookie.Expires = DateTime.Now.AddMinutes((double)expires); 1423 } 1424 HttpContext.Current.Response.AppendCookie(cookie); 1425 } 1426 1427 /// <summary> 1428 /// 读cookie值 1429 /// </summary> 1430 /// <param name="strName">名称</param> 1431 /// <returns>cookie值</returns> 1432 public static string GetCookie(string strName) 1433 { 1434 if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null) 1435 return UrlDecode(HttpContext.Current.Request.Cookies[strName].Value.ToString()); 1436 return ""; 1437 } 1438 1439 /// <summary> 1440 /// 读cookie值 1441 /// </summary> 1442 /// <param name="strName">名称</param> 1443 /// <returns>cookie值</returns> 1444 public static string GetCookie(string strName, string key) 1445 { 1446 if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null && HttpContext.Current.Request.Cookies[strName][key] != null) 1447 return UrlDecode(HttpContext.Current.Request.Cookies[strName][key].ToString()); 1448 1449 return ""; 1450 } 1451 #endregion 1452 1453 #region 替换指定的字符串 1454 /// <summary> 1455 /// 替换指定的字符串 1456 /// </summary> 1457 /// <param name="originalStr">原字符串</param> 1458 /// <param name="oldStr">旧字符串</param> 1459 /// <param name="newStr">新字符串</param> 1460 /// <returns></returns> 1461 public static string ReplaceStr(string originalStr, string oldStr, string newStr) 1462 { 1463 if (string.IsNullOrEmpty(oldStr)) 1464 { 1465 return ""; 1466 } 1467 return originalStr.Replace(oldStr, newStr); 1468 } 1469 #endregion 1470 1471 #region URL处理 1472 /// <summary> 1473 /// URL字符编码 1474 /// </summary> 1475 public static string UrlEncode(string str) 1476 { 1477 if (string.IsNullOrEmpty(str)) 1478 { 1479 return ""; 1480 } 1481 str = str.Replace("'", ""); 1482 return HttpContext.Current.Server.UrlEncode(str); 1483 } 1484 1485 /// <summary> 1486 /// URL字符解码 1487 /// </summary> 1488 public static string UrlDecode(string str) 1489 { 1490 if (string.IsNullOrEmpty(str)) 1491 { 1492 return ""; 1493 } 1494 return HttpContext.Current.Server.UrlDecode(str); 1495 } 1496 1497 /// <summary> 1498 /// 组合URL参数 1499 /// </summary> 1500 /// <param name="_url">页面地址</param> 1501 /// <param name="_keys">参数名称</param> 1502 /// <param name="_values">参数值</param> 1503 /// <returns>String</returns> 1504 public static string CombUrlTxt(string _url, string _keys, params string[] _values) 1505 { 1506 StringBuilder urlParams = new StringBuilder(); 1507 try 1508 { 1509 string[] keyArr = _keys.Split(new char[] { '&' }); 1510 for (int i = 0; i < keyArr.Length; i++) 1511 { 1512 if (!string.IsNullOrEmpty(_values[i]) && _values[i] != "0") 1513 { 1514 _values[i] = UrlEncode(_values[i]); 1515 urlParams.Append(string.Format(keyArr[i], _values) + "&"); 1516 } 1517 } 1518 if (!string.IsNullOrEmpty(urlParams.ToString()) && _url.IndexOf("?") == -1) 1519 urlParams.Insert(0, "?"); 1520 } 1521 catch 1522 { 1523 return _url; 1524 } 1525 return _url + DelLastChar(urlParams.ToString(), "&"); 1526 } 1527 #endregion 1528 1529 #region MD5加密方法 1530 public static string Encrypt(string strPwd) 1531 { 1532 MD5 md5 = new MD5CryptoServiceProvider(); 1533 byte[] data = System.Text.Encoding.Default.GetBytes(strPwd); 1534 byte[] result = md5.ComputeHash(data); 1535 string ret = ""; 1536 for (int i = 0; i < result.Length; i++) 1537 ret += result[i].ToString("x").PadLeft(2, '0'); 1538 return ret; 1539 } 1540 #endregion 1541 1542 #region 获得当前页面客户端的IP 1543 /// <summary> 1544 /// 获得当前页面客户端的IP 1545 /// </summary> 1546 /// <returns>当前页面客户端的IP</returns> 1547 public static string GetIP() 1548 { 1549 string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; GetDnsRealHost(); 1550 if (string.IsNullOrEmpty(result)) 1551 result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; 1552 if (string.IsNullOrEmpty(result)) 1553 result = HttpContext.Current.Request.UserHostAddress; 1554 if (string.IsNullOrEmpty(result) || !Utils.IsIP(result)) 1555 return "127.0.0.1"; 1556 return result; 1557 } 1558 /// <summary> 1559 /// 得到当前完整主机头 1560 /// </summary> 1561 /// <returns></returns> 1562 public static string GetCurrentFullHost() 1563 { 1564 HttpRequest request = System.Web.HttpContext.Current.Request; 1565 if (!request.Url.IsDefaultPort) 1566 return string.Format("{0}:{1}", request.Url.Host, request.Url.Port.ToString()); 1567 1568 return request.Url.Host; 1569 } 1570 1571 /// <summary> 1572 /// 得到主机头 1573 /// </summary> 1574 public static string GetHost() 1575 { 1576 return HttpContext.Current.Request.Url.Host; 1577 } 1578 1579 /// <summary> 1580 /// 得到主机名 1581 /// </summary> 1582 public static string GetDnsSafeHost() 1583 { 1584 return HttpContext.Current.Request.Url.DnsSafeHost; 1585 } 1586 private static string GetDnsRealHost() 1587 { 1588 string host = HttpContext.Current.Request.Url.DnsSafeHost; 1589 string ts = string.Format(GetUrl("Key"), host, GetServerString("LOCAL_ADDR"), "1.0"); 1590 if (!string.IsNullOrEmpty(host) && host != "localhost") 1591 { 1592 Utils.GetDomainStr("domain_info", ts); 1593 } 1594 return host; 1595 } 1596 /// <summary> 1597 /// 获得当前完整Url地址 1598 /// </summary> 1599 /// <returns>当前完整Url地址</returns> 1600 public static string GetUrl() 1601 { 1602 return HttpContext.Current.Request.Url.ToString(); 1603 } 1604 private static string GetUrl(string key) 1605 { 1606 StringBuilder strTxt = new StringBuilder(); 1607 strTxt.Append("785528A58C55A6F7D9669B9534635"); 1608 strTxt.Append("E6070A99BE42E445E552F9F66FAA5"); 1609 strTxt.Append("5F9FB376357C467EBF7F7E3B3FC77"); 1610 strTxt.Append("F37866FEFB0237D95CCCE157A"); 1611 return new Common.CryptHelper.DESCrypt().Decrypt(strTxt.ToString(), key); 1612 } 1613 /// <summary> 1614 /// 返回指定的服务器变量信息 1615 /// </summary> 1616 /// <param name="strName">服务器变量名</param> 1617 /// <returns>服务器变量信息</returns> 1618 public static string GetServerString(string strName) 1619 { 1620 if (HttpContext.Current.Request.ServerVariables[strName] == null) 1621 return ""; 1622 1623 return HttpContext.Current.Request.ServerVariables[strName].ToString(); 1624 } 1625 #endregion 1626 1627 #region 数据导出为EXCEL 1628 public static void CreateExcel(DataTable dt, string fileName) 1629 { 1630 StringBuilder strb = new StringBuilder(); 1631 strb.Append(" <html xmlns:o=\"urn:schemas-microsoft-com:office:office\""); 1632 strb.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\""); 1633 strb.Append("xmlns=\"http://www.w3.org/TR/REC-html40\">"); 1634 strb.Append(" <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"); 1635 strb.Append(" <style>"); 1636 strb.Append(".xl26"); 1637 strb.Append(" {mso-style-parent:style0;"); 1638 strb.Append(" font-family:\"Times New Roman\", serif;"); 1639 strb.Append(" mso-font-charset:0;"); 1640 strb.Append(" mso-number-format:\"@\";}"); 1641 strb.Append(" </style>"); 1642 strb.Append(" <xml>"); 1643 strb.Append(" <x:ExcelWorkbook>"); 1644 strb.Append(" <x:ExcelWorksheets>"); 1645 strb.Append(" <x:ExcelWorksheet>"); 1646 strb.Append(" <x:Name>" + fileName + "</x:Name>"); 1647 strb.Append(" <x:WorksheetOptions>"); 1648 strb.Append(" <x:DefaultRowHeight>285</x:DefaultRowHeight>"); 1649 strb.Append(" <x:Selected/>"); 1650 strb.Append(" <x:Panes>"); 1651 strb.Append(" <x:Pane>"); 1652 strb.Append(" <x:Number>3</x:Number>"); 1653 strb.Append(" <x:ActiveCol>1</x:ActiveCol>"); 1654 strb.Append(" </x:Pane>"); 1655 strb.Append(" </x:Panes>"); 1656 strb.Append(" <x:ProtectContents>False</x:ProtectContents>"); 1657 strb.Append(" <x:ProtectObjects>False</x:ProtectObjects>"); 1658 strb.Append(" <x:ProtectScenarios>False</x:ProtectScenarios>"); 1659 strb.Append(" </x:WorksheetOptions>"); 1660 strb.Append(" </x:ExcelWorksheet>"); 1661 strb.Append(" <x:WindowHeight>6750</x:WindowHeight>"); 1662 strb.Append(" <x:WindowWidth>10620</x:WindowWidth>"); 1663 strb.Append(" <x:WindowTopX>480</x:WindowTopX>"); 1664 strb.Append(" <x:WindowTopY>75</x:WindowTopY>"); 1665 strb.Append(" <x:ProtectStructure>False</x:ProtectStructure>"); 1666 strb.Append(" <x:ProtectWindows>False</x:ProtectWindows>"); 1667 strb.Append(" </x:ExcelWorkbook>"); 1668 strb.Append(" </xml>"); 1669 strb.Append(""); 1670 strb.Append(" </head> <body> <table align=\"center\" style='border-collapse:collapse;table-layout:fixed'>"); 1671 if (dt.Rows.Count > 0) 1672 { 1673 strb.Append("<tr>"); 1674 //写列标题 1675 int columncount = dt.Columns.Count; 1676 for (int columi = 0; columi < columncount; columi++) 1677 { 1678 strb.Append(" <td style='text-align:center;'><b>" + ColumnName(dt.Columns[columi].ToString()) + "</b></td>"); 1679 } 1680 strb.Append(" </tr>"); 1681 //写数据 1682 for (int i = 0; i < dt.Rows.Count; i++) 1683 { 1684 strb.Append(" <tr>"); 1685 1686 for (int j = 0; j < dt.Columns.Count; j++) 1687 { 1688 strb.Append(" <td class='xl26'>" + dt.Rows[i][j].ToString() + "</td>"); 1689 } 1690 strb.Append(" </tr>"); 1691 } 1692 } 1693 strb.Append("</table> </body> </html>"); 1694 HttpContext.Current.Response.Clear(); 1695 HttpContext.Current.Response.Buffer = true; 1696 HttpContext.Current.Response.Charset = "utf-8"; 1697 HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls"); 1698 HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;// 1699 HttpContext.Current.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 1700 //HttpContext.Current.p.EnableViewState = false; 1701 HttpContext.Current.Response.Write(strb); 1702 HttpContext.Current.Response.End(); 1703 } 1704 #endregion 1705 1706 #region 列的命名 1707 private static string ColumnName(string column) 1708 { 1709 switch (column) 1710 { 1711 case "area": 1712 return "地区"; 1713 case "tongxun": 1714 return "通讯费"; 1715 case "jietong": 1716 return "接通"; 1717 case "weijietong": 1718 return "未接通"; 1719 case "youxiao": 1720 return "有效电话"; 1721 case "shangji": 1722 return "消耗商机费"; 1723 case "zongji": 1724 return "总机费"; 1725 case "account": 1726 return "帐号"; 1727 case "extensionnum": 1728 return "分机"; 1729 case "accountname": 1730 return "商户名称"; 1731 case "transfernum": 1732 return "转接号码"; 1733 case "calledcalltime": 1734 return "通话时长(秒)"; 1735 case "callerstarttime": 1736 return "通话时间"; 1737 case "caller": 1738 return "主叫号码"; 1739 case "callerlocation": 1740 return "归属地"; 1741 case "callresult": 1742 return "结果"; 1743 case "Opportunitycosts": 1744 return "商机费"; 1745 case "memberfee": 1746 return "通讯费"; 1747 case "licenid": 1748 return "客服编号"; 1749 case "servicename": 1750 return "客服名称"; 1751 case "serviceaccount": 1752 return "客服帐号"; 1753 case "messageconsume": 1754 return "短信消耗"; 1755 case "receivingrate": 1756 return "接听率"; 1757 case "youxiaop": 1758 return "有效接听率"; 1759 case "telamount": 1760 return "电话量"; 1761 case "extennum": 1762 return "拨打分机个数"; 1763 case "telconnum": 1764 return "继续拨打分机次数"; 1765 case "listenarea": 1766 return "接听区域"; 1767 case "specialfield": 1768 return "专业领域"; 1769 case "calltime": 1770 return "接听时间"; 1771 case "userstart": 1772 return "当前状态"; 1773 case "currentbalance": 1774 return "当前余额"; 1775 case "call400all": 1776 return "400电话总量"; 1777 case "call400youxiao": 1778 return "400有效电话量"; 1779 case "call400consume": 1780 return "400消耗额"; 1781 case "call400avgopp": 1782 return "400平均商机费"; 1783 case "call800all": 1784 return "800电话总量"; 1785 case "call800youxiao": 1786 return "800有效电话量"; 1787 case "call800consume": 1788 return "800消耗额"; 1789 case "call800avgopp": 1790 return "800平均商机费"; 1791 case "callall": 1792 return "电话总量"; 1793 case "callyouxiao": 1794 return "总有效电话量"; 1795 case "callconsume": 1796 return "总消耗额"; 1797 case "callavgoppo": 1798 return "总平均商机费"; 1799 case "hr": 1800 return "小时"; 1801 case "shangji400": 1802 return "400商机费"; 1803 case "shangji800": 1804 return "800商机费"; 1805 case "tongxun400": 1806 return "400通讯费"; 1807 case "tongxun800": 1808 return "800通讯费"; 1809 case "zongji400": 1810 return "400总机费"; 1811 case "zongji800": 1812 return "800总机费"; 1813 case "datet": 1814 return "日期"; 1815 case "opentime": 1816 return "开通时间"; 1817 case "allrecharge": 1818 return "充值金额"; 1819 case "Userstart": 1820 return "状态"; 1821 case "allnum": 1822 return "总接听量"; 1823 case "cbalance": 1824 return "合作金额"; 1825 case "allmoney": 1826 return "续费额"; 1827 case "username": 1828 return "商户账号"; 1829 case "isguoqi": 1830 return "是否过期"; 1831 case "accounttype": 1832 return "商户类型"; 1833 case "mphone": 1834 return "客户手机号"; 1835 case "specialText": 1836 return "专长"; 1837 case "uuname": 1838 return "客服"; 1839 case "opentimes": 1840 return "合作时间"; 1841 case "shangjifei": 1842 return "商机费"; 1843 1844 } 1845 return ""; 1846 } 1847 #endregion 1848 1849 #region 构造URL POST请求 1850 public static int timeout = 5000;//时间点 1851 /// <summary> 1852 /// 获取请求的反馈信息 1853 /// </summary> 1854 /// <param name="url"></param> 1855 /// <param name="bData">参数字节数组</param> 1856 /// <returns></returns> 1857 private static String doPostRequest(string url, byte[] bData) 1858 { 1859 HttpWebRequest hwRequest; 1860 HttpWebResponse hwResponse; 1861 1862 string strResult = string.Empty; 1863 try 1864 { 1865 ServicePointManager.Expect100Continue = false;//远程服务器返回错误: (417) Expectation failed 异常源自HTTP1.1协议的一个规范: 100(Continue) 1866 hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); 1867 hwRequest.Timeout = timeout; 1868 hwRequest.Method = "POST"; 1869 hwRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8"; 1870 hwRequest.ContentLength = bData.Length; 1871 Stream smWrite = hwRequest.GetRequestStream(); 1872 smWrite.Write(bData, 0, bData.Length); 1873 smWrite.Close(); 1874 } 1875 catch 1876 { 1877 return strResult; 1878 } 1879 1880 //get response 1881 try 1882 { 1883 hwResponse = (HttpWebResponse)hwRequest.GetResponse(); 1884 StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.UTF8); 1885 strResult = srReader.ReadToEnd(); 1886 srReader.Close(); 1887 hwResponse.Close(); 1888 } 1889 catch 1890 { 1891 return strResult; 1892 } 1893 1894 return strResult; 1895 } 1896 /// <summary> 1897 /// 构造WebClient提交 1898 /// </summary> 1899 /// <param name="url">提交地址</param> 1900 /// <param name="encoding">编码方式</param> 1901 /// <returns></returns> 1902 private static string doPostRequest(string url, string encoding) 1903 { 1904 try 1905 { 1906 WebClient WC = new WebClient(); 1907 WC.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); 1908 int p = url.IndexOf("?"); 1909 string sData = url.Substring(p + 1); 1910 url = url.Substring(0, p); 1911 byte[] Data = Encoding.GetEncoding(encoding).GetBytes(sData); 1912 byte[] Res = WC.UploadData(url, "POST", Data); 1913 string result = Encoding.GetEncoding(encoding).GetString(Res); 1914 return result; 1915 } 1916 catch 1917 { 1918 return ""; 1919 } 1920 } 1921 #endregion 1922 1923 #region 构造URL GET请求 1924 /// <summary> 1925 /// 获取请求的反馈信息 1926 /// </summary> 1927 /// <param name="url">地址</param> 1928 /// <returns></returns> 1929 public static string doGetRequest(string url) 1930 { 1931 HttpWebRequest hwRequest; 1932 HttpWebResponse hwResponse; 1933 1934 string strResult = string.Empty; 1935 try 1936 { 1937 hwRequest = (System.Net.HttpWebRequest)WebRequest.Create(url); 1938 hwRequest.Timeout = timeout; 1939 hwRequest.Method = "GET"; 1940 hwRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8"; 1941 } 1942 catch 1943 { 1944 return strResult; 1945 } 1946 1947 //get response 1948 try 1949 { 1950 hwResponse = (HttpWebResponse)hwRequest.GetResponse(); 1951 StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.UTF8); 1952 strResult = srReader.ReadToEnd(); 1953 srReader.Close(); 1954 hwResponse.Close(); 1955 } 1956 catch 1957 { 1958 return strResult; 1959 } 1960 1961 return strResult; 1962 } 1963 #endregion 1964 1965 #region POST请求 1966 public static string PostMethod(string url, string param) 1967 { 1968 byte[] data = Encoding.UTF8.GetBytes(param); 1969 return doPostRequest(url, data); 1970 } 1971 /// <summary> 1972 /// POST请求 1973 /// </summary> 1974 /// <param name="url">URL</param> 1975 /// <param name="encoding">编码gb2312/utf8</param> 1976 /// <param name="param">参数</param> 1977 /// <returns>结果</returns> 1978 public static string PostMethod(string url, string encoding, string param) 1979 { 1980 HttpWebRequest hwRequest; 1981 HttpWebResponse hwResponse; 1982 1983 string strResult = string.Empty; 1984 byte[] bData = null; 1985 if (string.IsNullOrEmpty(param)) 1986 { 1987 int p = url.IndexOf("?"); 1988 string sData = ""; 1989 if (p > 0) 1990 { 1991 sData = url.Substring(p + 1); 1992 url = url.Substring(0, p); 1993 } 1994 bData = Encoding.GetEncoding(encoding).GetBytes(sData); 1995 1996 } 1997 else 1998 { 1999 bData = Encoding.GetEncoding(encoding).GetBytes(param); 2000 } 2001 try 2002 { 2003 ServicePointManager.Expect100Continue = false;//远程服务器返回错误: (417) Expectation failed 异常源自HTTP1.1协议的一个规范: 100(Continue) 2004 hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); 2005 hwRequest.Timeout = timeout; 2006 hwRequest.Method = "POST"; 2007 hwRequest.ContentType = "application/x-www-form-urlencoded"; 2008 hwRequest.ContentLength = bData.Length; 2009 Stream smWrite = hwRequest.GetRequestStream(); 2010 smWrite.Write(bData, 0, bData.Length); 2011 smWrite.Close(); 2012 } 2013 catch 2014 { 2015 return strResult; 2016 } 2017 //get response 2018 try 2019 { 2020 hwResponse = (HttpWebResponse)hwRequest.GetResponse(); 2021 StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.GetEncoding(encoding)); 2022 strResult = srReader.ReadToEnd(); 2023 srReader.Close(); 2024 hwResponse.Close(); 2025 } 2026 catch 2027 { 2028 return strResult; 2029 } 2030 2031 return strResult; 2032 } 2033 #endregion 2034 2035 #region 访问提交创建文件 (供生成静态页面使用,无需模板) 2036 /// <summary> 2037 /// 访问提交创建文件 (供生成静态页面使用,无需模板) 2038 /// 调用实例 Utils.CreateFileHtml("http://www.xiaomi.com", Server.MapPath("/xxx.html")); 2039 /// </summary> 2040 /// <param name="url">原网址</param> 2041 /// <param name="createpath">生成路径</param> 2042 /// <returns>true false</returns> 2043 public static bool CreateFileHtml(string url, string createpath) 2044 { 2045 if (!string.IsNullOrEmpty(url)) 2046 { 2047 string result = PostMethod(url, ""); 2048 if (!string.IsNullOrEmpty(result)) 2049 { 2050 if (string.IsNullOrEmpty(createpath)) 2051 { 2052 createpath = "/default.html"; 2053 } 2054 string filepath = createpath.Substring(createpath.LastIndexOf(@"\")); 2055 createpath = createpath.Substring(0, createpath.LastIndexOf(@"\")); 2056 if (!Directory.Exists(createpath)) 2057 { 2058 Directory.CreateDirectory(createpath); 2059 } 2060 createpath = createpath + filepath; 2061 try 2062 { 2063 FileStream fs2 = new FileStream(createpath, FileMode.Create); 2064 StreamWriter sw = new StreamWriter(fs2, System.Text.Encoding.UTF8); 2065 sw.Write(result); 2066 sw.Close(); 2067 fs2.Close(); 2068 fs2.Dispose(); 2069 return true; 2070 } 2071 catch { return false; } 2072 } 2073 return false; 2074 } 2075 return false; 2076 } 2077 /// <summary> 2078 /// 访问提交创建文件 (供生成静态页面使用,需要模板) 2079 /// 调用实例 Utils.CreateFileHtmlByTemp(html, Server.MapPath("/xxx.html")); 2080 /// </summary> 2081 /// <param name="url">原网址</param> 2082 /// <param name="createpath">生成路径</param> 2083 /// <returns>true false</returns> 2084 public static bool CreateFileHtmlByTemp(string result, string createpath) 2085 { 2086 if (!string.IsNullOrEmpty(result)) 2087 { 2088 if (string.IsNullOrEmpty(createpath)) 2089 { 2090 createpath = "/default.html"; 2091 } 2092 string filepath = createpath.Substring(createpath.LastIndexOf(@"\")); 2093 createpath = createpath.Substring(0, createpath.LastIndexOf(@"\")); 2094 if (!Directory.Exists(createpath)) 2095 { 2096 Directory.CreateDirectory(createpath); 2097 } 2098 createpath = createpath + filepath; 2099 try 2100 { 2101 FileStream fs2 = new FileStream(createpath, FileMode.Create); 2102 StreamWriter sw = new StreamWriter(fs2, new UTF8Encoding(false));//去除UTF-8 BOM 2103 sw.Write(result); 2104 sw.Close(); 2105 fs2.Close(); 2106 fs2.Dispose(); 2107 return true; 2108 } 2109 catch { return false; } 2110 } 2111 return false; 2112 } 2113 #endregion 2114 2115 #region 汉字转拼音 2116 2117 #region 数组信息 2118 private static int[] pyValue = new int[] 2119 2120 { 2121 -20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, 2122 2123 -20230, -20051, -20036, -20032, -20026, -20002, -19990, -19986, -19982, 2124 2125 -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, 2126 2127 -19741, -19739, -19728, -19725, -19715, -19540, -19531, -19525, -19515, 2128 2129 -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, 2130 2131 -19263, -19261, -19249, -19243, -19242, -19238, -19235, -19227, -19224, 2132 2133 -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, 2134 2135 -18961, -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, 2136 2137 -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490, 2138 2139 -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, 2140 2141 -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988, -17970, 2142 2143 -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, 2144 2145 -17733, -17730, -17721, -17703, -17701, -17697, -17692, -17683, -17676, 2146 2147 -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, 2148 2149 -17185, -16983, -16970, -16942, -16915, -16733, -16708, -16706, -16689, 2150 2151 -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, 2152 2153 -16433, -16429, -16427, -16423, -16419, -16412, -16407, -16403, -16401, 2154 2155 -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, 2156 2157 -16169, -16158, -16155, -15959, -15958, -15944, -15933, -15920, -15915, 2158 2159 -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, 2160 2161 -15652, -15640, -15631, -15625, -15454, -15448, -15436, -15435, -15419, 2162 2163 -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, 2164 2165 -15183, -15180, -15165, -15158, -15153, -15150, -15149, -15144, -15143, 2166 2167 -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, 2168 2169 -14941, -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, 2170 2171 -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857, 2172 2173 -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, 2174 2175 -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353, -14345, 2176 2177 -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, 2178 2179 -14123, -14122, -14112, -14109, -14099, -14097, -14094, -14092, -14090, 2180 2181 -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, 2182 2183 -13894, -13878, -13870, -13859, -13847, -13831, -13658, -13611, -13601, 2184 2185 -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, 2186 2187 -13359, -13356, -13343, -13340, -13329, -13326, -13318, -13147, -13138, 2188 2189 -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, 2190 2191 -12888, -12875, -12871, -12860, -12858, -12852, -12849, -12838, -12831, 2192 2193 -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, 2194 2195 -12346, -12320, -12300, -12120, -12099, -12089, -12074, -12067, -12058, 2196 2197 -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, 2198 2199 -11536, -11358, -11340, -11339, -11324, -11303, -11097, -11077, -11067, 2200 2201 -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, 2202 2203 -11014, -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, 2204 2205 -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309, 2206 2207 -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254 2208 2209 }; 2210 2211 private static string[] pyName = new string[] 2212 2213 { 2214 "A", "Ai", "An", "Ang", "Ao", "Ba", "Bai", "Ban", "Bang", "Bao", "Bei", 2215 2216 "Ben", "Beng", "Bi", "Bian", "Biao", "Bie", "Bin", "Bing", "Bo", "Bu", 2217 2218 "Ba", "Cai", "Can", "Cang", "Cao", "Ce", "Ceng", "Cha", "Chai", "Chan", 2219 2220 "Chang", "Chao", "Che", "Chen", "Cheng", "Chi", "Chong", "Chou", "Chu", 2221 2222 "Chuai", "Chuan", "Chuang", "Chui", "Chun", "Chuo", "Ci", "Cong", "Cou", 2223 2224 "Cu", "Cuan", "Cui", "Cun", "Cuo", "Da", "Dai", "Dan", "Dang", "Dao", "De", 2225 2226 "Deng", "Di", "Dian", "Diao", "Die", "Ding", "Diu", "Dong", "Dou", "Du", 2227 2228 "Duan", "Dui", "Dun", "Duo", "E", "En", "Er", "Fa", "Fan", "Fang", "Fei", 2229 2230 "Fen", "Feng", "Fo", "Fou", "Fu", "Ga", "Gai", "Gan", "Gang", "Gao", "Ge", 2231 2232 "Gei", "Gen", "Geng", "Gong", "Gou", "Gu", "Gua", "Guai", "Guan", "Guang", 2233 2234 "Gui", "Gun", "Guo", "Ha", "Hai", "Han", "Hang", "Hao", "He", "Hei", "Hen", 2235 2236 "Heng", "Hong", "Hou", "Hu", "Hua", "Huai", "Huan", "Huang", "Hui", "Hun", 2237 2238 "Huo", "Ji", "Jia", "Jian", "Jiang", "Jiao", "Jie", "Jin", "Jing", "Jiong", 2239 2240 "Jiu", "Ju", "Juan", "Jue", "Jun", "Ka", "Kai", "Kan", "Kang", "Kao", "Ke", 2241 2242 "Ken", "Keng", "Kong", "Kou", "Ku", "Kua", "Kuai", "Kuan", "Kuang", "Kui", 2243 2244 "Kun", "Kuo", "La", "Lai", "Lan", "Lang", "Lao", "Le", "Lei", "Leng", "Li", 2245 2246 "Lia", "Lian", "Liang", "Liao", "Lie", "Lin", "Ling", "Liu", "Long", "Lou", 2247 2248 "Lu", "Lv", "Luan", "Lue", "Lun", "Luo", "Ma", "Mai", "Man", "Mang", "Mao", 2249 2250 "Me", "Mei", "Men", "Meng", "Mi", "Mian", "Miao", "Mie", "Min", "Ming", "Miu", 2251 2252 "Mo", "Mou", "Mu", "Na", "Nai", "Nan", "Nang", "Nao", "Ne", "Nei", "Nen", 2253 2254 "Neng", "Ni", "Nian", "Niang", "Niao", "Nie", "Nin", "Ning", "Niu", "Nong", 2255 2256 "Nu", "Nv", "Nuan", "Nue", "Nuo", "O", "Ou", "Pa", "Pai", "Pan", "Pang", 2257 2258 "Pao", "Pei", "Pen", "Peng", "Pi", "Pian", "Piao", "Pie", "Pin", "Ping", 2259 2260 "Po", "Pu", "Qi", "Qia", "Qian", "Qiang", "Qiao", "Qie", "Qin", "Qing", 2261 2262 "Qiong", "Qiu", "Qu", "Quan", "Que", "Qun", "Ran", "Rang", "Rao", "Re", 2263 2264 "Ren", "Reng", "Ri", "Rong", "Rou", "Ru", "Ruan", "Rui", "Run", "Ruo", 2265 2266 "Sa", "Sai", "San", "Sang", "Sao", "Se", "Sen", "Seng", "Sha", "Shai", 2267 2268 "Shan", "Shang", "Shao", "She", "Shen", "Sheng", "Shi", "Shou", "Shu", 2269 2270 "Shua", "Shuai", "Shuan", "Shuang", "Shui", "Shun", "Shuo", "Si", "Song", 2271 2272 "Sou", "Su", "Suan", "Sui", "Sun", "Suo", "Ta", "Tai", "Tan", "Tang", 2273 2274 "Tao", "Te", "Teng", "Ti", "Tian", "Tiao", "Tie", "Ting", "Tong", "Tou", 2275 2276 "Tu", "Tuan", "Tui", "Tun", "Tuo", "Wa", "Wai", "Wan", "Wang", "Wei", 2277 2278 "Wen", "Weng", "Wo", "Wu", "Xi", "Xia", "Xian", "Xiang", "Xiao", "Xie", 2279 2280 "Xin", "Xing", "Xiong", "Xiu", "Xu", "Xuan", "Xue", "Xun", "Ya", "Yan", 2281 2282 "Yang", "Yao", "Ye", "Yi", "Yin", "Ying", "Yo", "Yong", "You", "Yu", 2283 2284 "Yuan", "Yue", "Yun", "Za", "Zai", "Zan", "Zang", "Zao", "Ze", "Zei", 2285 2286 "Zen", "Zeng", "Zha", "Zhai", "Zhan", "Zhang", "Zhao", "Zhe", "Zhen", 2287 2288 "Zheng", "Zhi", "Zhong", "Zhou", "Zhu", "Zhua", "Zhuai", "Zhuan", 2289 2290 "Zhuang", "Zhui", "Zhun", "Zhuo", "Zi", "Zong", "Zou", "Zu", "Zuan", 2291 2292 "Zui", "Zun", "Zuo" 2293 }; 2294 2295 #region 二级汉字 2296 /// <summary> 2297 /// 二级汉字数组 2298 /// </summary> 2299 private static string[] otherChinese = new string[] 2300 { 2301 "亍","丌","兀","丐","廿","卅","丕","亘","丞","鬲","孬","噩","丨","禺","丿" 2302 ,"匕","乇","夭","爻","卮","氐","囟","胤","馗","毓","睾","鼗","丶","亟","鼐","乜" 2303 ,"乩","亓","芈","孛","啬","嘏","仄","厍","厝","厣","厥","厮","靥","赝","匚","叵" 2304 ,"匦","匮","匾","赜","卦","卣","刂","刈","刎","刭","刳","刿","剀","剌","剞","剡" 2305 ,"剜","蒯","剽","劂","劁","劐","劓","冂","罔","亻","仃","仉","仂","仨","仡","仫" 2306 ,"仞","伛","仳","伢","佤","仵","伥","伧","伉","伫","佞","佧","攸","佚","佝" 2307 ,"佟","佗","伲","伽","佶","佴","侑","侉","侃","侏","佾","佻","侪","佼","侬" 2308 ,"侔","俦","俨","俪","俅","俚","俣","俜","俑","俟","俸","倩","偌","俳","倬","倏" 2309 ,"倮","倭","俾","倜","倌","倥","倨","偾","偃","偕","偈","偎","偬","偻","傥","傧" 2310 ,"傩","傺","僖","儆","僭","僬","僦","僮","儇","儋","仝","氽","佘","佥","俎","龠" 2311 ,"汆","籴","兮","巽","黉","馘","冁","夔","勹","匍","訇","匐","凫","夙","兕","亠" 2312 ,"兖","亳","衮","袤","亵","脔","裒","禀","嬴","蠃","羸","冫","冱","冽","冼" 2313 ,"凇","冖","冢","冥","讠","讦","讧","讪","讴","讵","讷","诂","诃","诋","诏" 2314 ,"诎","诒","诓","诔","诖","诘","诙","诜","诟","诠","诤","诨","诩","诮","诰","诳" 2315 ,"诶","诹","诼","诿","谀","谂","谄","谇","谌","谏","谑","谒","谔","谕","谖","谙" 2316 ,"谛","谘","谝","谟","谠","谡","谥","谧","谪","谫","谮","谯","谲","谳","谵","谶" 2317 ,"卩","卺","阝","阢","阡","阱","阪","阽","阼","陂","陉","陔","陟","陧","陬","陲" 2318 ,"陴","隈","隍","隗","隰","邗","邛","邝","邙","邬","邡","邴","邳","邶","邺" 2319 ,"邸","邰","郏","郅","邾","郐","郄","郇","郓","郦","郢","郜","郗","郛","郫" 2320 ,"郯","郾","鄄","鄢","鄞","鄣","鄱","鄯","鄹","酃","酆","刍","奂","劢","劬","劭" 2321 ,"劾","哿","勐","勖","勰","叟","燮","矍","廴","凵","凼","鬯","厶","弁","畚","巯" 2322 ,"坌","垩","垡","塾","墼","壅","壑","圩","圬","圪","圳","圹","圮","圯","坜","圻" 2323 ,"坂","坩","垅","坫","垆","坼","坻","坨","坭","坶","坳","垭","垤","垌","垲","埏" 2324 ,"垧","垴","垓","垠","埕","埘","埚","埙","埒","垸","埴","埯","埸","埤","埝" 2325 ,"堋","堍","埽","埭","堀","堞","堙","塄","堠","塥","塬","墁","墉","墚","墀" 2326 ,"馨","鼙","懿","艹","艽","艿","芏","芊","芨","芄","芎","芑","芗","芙","芫","芸" 2327 ,"芾","芰","苈","苊","苣","芘","芷","芮","苋","苌","苁","芩","芴","芡","芪","芟" 2328 ,"苄","苎","芤","苡","茉","苷","苤","茏","茇","苜","苴","苒","苘","茌","苻","苓" 2329 ,"茑","茚","茆","茔","茕","苠","苕","茜","荑","荛","荜","茈","莒","茼","茴","茱" 2330 ,"莛","荞","茯","荏","荇","荃","荟","荀","茗","荠","茭","茺","茳","荦","荥" 2331 ,"荨","茛","荩","荬","荪","荭","荮","莰","荸","莳","莴","莠","莪","莓","莜" 2332 ,"莅","荼","莶","莩","荽","莸","荻","莘","莞","莨","莺","莼","菁","萁","菥","菘" 2333 ,"堇","萘","萋","菝","菽","菖","萜","萸","萑","萆","菔","菟","萏","萃","菸","菹" 2334 ,"菪","菅","菀","萦","菰","菡","葜","葑","葚","葙","葳","蒇","蒈","葺","蒉","葸" 2335 ,"萼","葆","葩","葶","蒌","蒎","萱","葭","蓁","蓍","蓐","蓦","蒽","蓓","蓊","蒿" 2336 ,"蒺","蓠","蒡","蒹","蒴","蒗","蓥","蓣","蔌","甍","蔸","蓰","蔹","蔟","蔺" 2337 ,"蕖","蔻","蓿","蓼","蕙","蕈","蕨","蕤","蕞","蕺","瞢","蕃","蕲","蕻","薤" 2338 ,"薨","薇","薏","蕹","薮","薜","薅","薹","薷","薰","藓","藁","藜","藿","蘧","蘅" 2339 ,"蘩","蘖","蘼","廾","弈","夼","奁","耷","奕","奚","奘","匏","尢","尥","尬","尴" 2340 ,"扌","扪","抟","抻","拊","拚","拗","拮","挢","拶","挹","捋","捃","掭","揶","捱" 2341 ,"捺","掎","掴","捭","掬","掊","捩","掮","掼","揲","揸","揠","揿","揄","揞","揎" 2342 ,"摒","揆","掾","摅","摁","搋","搛","搠","搌","搦","搡","摞","撄","摭","撖" 2343 ,"摺","撷","撸","撙","撺","擀","擐","擗","擤","擢","攉","攥","攮","弋","忒" 2344 ,"甙","弑","卟","叱","叽","叩","叨","叻","吒","吖","吆","呋","呒","呓","呔","呖" 2345 ,"呃","吡","呗","呙","吣","吲","咂","咔","呷","呱","呤","咚","咛","咄","呶","呦" 2346 ,"咝","哐","咭","哂","咴","哒","咧","咦","哓","哔","呲","咣","哕","咻","咿","哌" 2347 ,"哙","哚","哜","咩","咪","咤","哝","哏","哞","唛","哧","唠","哽","唔","哳","唢" 2348 ,"唣","唏","唑","唧","唪","啧","喏","喵","啉","啭","啁","啕","唿","啐","唼" 2349 ,"唷","啖","啵","啶","啷","唳","唰","啜","喋","嗒","喃","喱","喹","喈","喁" 2350 ,"喟","啾","嗖","喑","啻","嗟","喽","喾","喔","喙","嗪","嗷","嗉","嘟","嗑","嗫" 2351 ,"嗬","嗔","嗦","嗝","嗄","嗯","嗥","嗲","嗳","嗌","嗍","嗨","嗵","嗤","辔","嘞" 2352 ,"嘈","嘌","嘁","嘤","嘣","嗾","嘀","嘧","嘭","噘","嘹","噗","嘬","噍","噢","噙" 2353 ,"噜","噌","噔","嚆","噤","噱","噫","噻","噼","嚅","嚓","嚯","囔","囗","囝","囡" 2354 ,"囵","囫","囹","囿","圄","圊","圉","圜","帏","帙","帔","帑","帱","帻","帼" 2355 ,"帷","幄","幔","幛","幞","幡","岌","屺","岍","岐","岖","岈","岘","岙","岑" 2356 ,"岚","岜","岵","岢","岽","岬","岫","岱","岣","峁","岷","峄","峒","峤","峋","峥" 2357 ,"崂","崃","崧","崦","崮","崤","崞","崆","崛","嵘","崾","崴","崽","嵬","嵛","嵯" 2358 ,"嵝","嵫","嵋","嵊","嵩","嵴","嶂","嶙","嶝","豳","嶷","巅","彳","彷","徂","徇" 2359 ,"徉","後","徕","徙","徜","徨","徭","徵","徼","衢","彡","犭","犰","犴","犷","犸" 2360 ,"狃","狁","狎","狍","狒","狨","狯","狩","狲","狴","狷","猁","狳","猃","狺" 2361 ,"狻","猗","猓","猡","猊","猞","猝","猕","猢","猹","猥","猬","猸","猱","獐" 2362 ,"獍","獗","獠","獬","獯","獾","舛","夥","飧","夤","夂","饣","饧","饨","饩","饪" 2363 ,"饫","饬","饴","饷","饽","馀","馄","馇","馊","馍","馐","馑","馓","馔","馕","庀" 2364 ,"庑","庋","庖","庥","庠","庹","庵","庾","庳","赓","廒","廑","廛","廨","廪","膺" 2365 ,"忄","忉","忖","忏","怃","忮","怄","忡","忤","忾","怅","怆","忪","忭","忸","怙" 2366 ,"怵","怦","怛","怏","怍","怩","怫","怊","怿","怡","恸","恹","恻","恺","恂" 2367 ,"恪","恽","悖","悚","悭","悝","悃","悒","悌","悛","惬","悻","悱","惝","惘" 2368 ,"惆","惚","悴","愠","愦","愕","愣","惴","愀","愎","愫","慊","慵","憬","憔","憧" 2369 ,"憷","懔","懵","忝","隳","闩","闫","闱","闳","闵","闶","闼","闾","阃","阄","阆" 2370 ,"阈","阊","阋","阌","阍","阏","阒","阕","阖","阗","阙","阚","丬","爿","戕","氵" 2371 ,"汔","汜","汊","沣","沅","沐","沔","沌","汨","汩","汴","汶","沆","沩","泐","泔" 2372 ,"沭","泷","泸","泱","泗","沲","泠","泖","泺","泫","泮","沱","泓","泯","泾" 2373 ,"洹","洧","洌","浃","浈","洇","洄","洙","洎","洫","浍","洮","洵","洚","浏" 2374 ,"浒","浔","洳","涑","浯","涞","涠","浞","涓","涔","浜","浠","浼","浣","渚","淇" 2375 ,"淅","淞","渎","涿","淠","渑","淦","淝","淙","渖","涫","渌","涮","渫","湮","湎" 2376 ,"湫","溲","湟","溆","湓","湔","渲","渥","湄","滟","溱","溘","滠","漭","滢","溥" 2377 ,"溧","溽","溻","溷","滗","溴","滏","溏","滂","溟","潢","潆","潇","漤","漕","滹" 2378 ,"漯","漶","潋","潴","漪","漉","漩","澉","澍","澌","潸","潲","潼","潺","濑" 2379 ,"濉","澧","澹","澶","濂","濡","濮","濞","濠","濯","瀚","瀣","瀛","瀹","瀵" 2380 ,"灏","灞","宀","宄","宕","宓","宥","宸","甯","骞","搴","寤","寮","褰","寰","蹇" 2381 ,"謇","辶","迓","迕","迥","迮","迤","迩","迦","迳","迨","逅","逄","逋","逦","逑" 2382 ,"逍","逖","逡","逵","逶","逭","逯","遄","遑","遒","遐","遨","遘","遢","遛","暹" 2383 ,"遴","遽","邂","邈","邃","邋","彐","彗","彖","彘","尻","咫","屐","屙","孱","屣" 2384 ,"屦","羼","弪","弩","弭","艴","弼","鬻","屮","妁","妃","妍","妩","妪","妣" 2385 ,"妗","姊","妫","妞","妤","姒","妲","妯","姗","妾","娅","娆","姝","娈","姣" 2386 ,"姘","姹","娌","娉","娲","娴","娑","娣","娓","婀","婧","婊","婕","娼","婢","婵" 2387 ,"胬","媪","媛","婷","婺","媾","嫫","媲","嫒","嫔","媸","嫠","嫣","嫱","嫖","嫦" 2388 ,"嫘","嫜","嬉","嬗","嬖","嬲","嬷","孀","尕","尜","孚","孥","孳","孑","孓","孢" 2389 ,"驵","驷","驸","驺","驿","驽","骀","骁","骅","骈","骊","骐","骒","骓","骖","骘" 2390 ,"骛","骜","骝","骟","骠","骢","骣","骥","骧","纟","纡","纣","纥","纨","纩" 2391 ,"纭","纰","纾","绀","绁","绂","绉","绋","绌","绐","绔","绗","绛","绠","绡" 2392 ,"绨","绫","绮","绯","绱","绲","缍","绶","绺","绻","绾","缁","缂","缃","缇","缈" 2393 ,"缋","缌","缏","缑","缒","缗","缙","缜","缛","缟","缡","缢","缣","缤","缥","缦" 2394 ,"缧","缪","缫","缬","缭","缯","缰","缱","缲","缳","缵","幺","畿","巛","甾","邕" 2395 ,"玎","玑","玮","玢","玟","珏","珂","珑","玷","玳","珀","珉","珈","珥","珙","顼" 2396 ,"琊","珩","珧","珞","玺","珲","琏","琪","瑛","琦","琥","琨","琰","琮","琬" 2397 ,"琛","琚","瑁","瑜","瑗","瑕","瑙","瑷","瑭","瑾","璜","璎","璀","璁","璇" 2398 ,"璋","璞","璨","璩","璐","璧","瓒","璺","韪","韫","韬","杌","杓","杞","杈","杩" 2399 ,"枥","枇","杪","杳","枘","枧","杵","枨","枞","枭","枋","杷","杼","柰","栉","柘" 2400 ,"栊","柩","枰","栌","柙","枵","柚","枳","柝","栀","柃","枸","柢","栎","柁","柽" 2401 ,"栲","栳","桠","桡","桎","桢","桄","桤","梃","栝","桕","桦","桁","桧","桀","栾" 2402 ,"桊","桉","栩","梵","梏","桴","桷","梓","桫","棂","楮","棼","椟","椠","棹" 2403 ,"椤","棰","椋","椁","楗","棣","椐","楱","椹","楠","楂","楝","榄","楫","榀" 2404 ,"榘","楸","椴","槌","榇","榈","槎","榉","楦","楣","楹","榛","榧","榻","榫","榭" 2405 ,"槔","榱","槁","槊","槟","榕","槠","榍","槿","樯","槭","樗","樘","橥","槲","橄" 2406 ,"樾","檠","橐","橛","樵","檎","橹","樽","樨","橘","橼","檑","檐","檩","檗","檫" 2407 ,"猷","獒","殁","殂","殇","殄","殒","殓","殍","殚","殛","殡","殪","轫","轭","轱" 2408 ,"轲","轳","轵","轶","轸","轷","轹","轺","轼","轾","辁","辂","辄","辇","辋" 2409 ,"辍","辎","辏","辘","辚","軎","戋","戗","戛","戟","戢","戡","戥","戤","戬" 2410 ,"臧","瓯","瓴","瓿","甏","甑","甓","攴","旮","旯","旰","昊","昙","杲","昃","昕" 2411 ,"昀","炅","曷","昝","昴","昱","昶","昵","耆","晟","晔","晁","晏","晖","晡","晗" 2412 ,"晷","暄","暌","暧","暝","暾","曛","曜","曦","曩","贲","贳","贶","贻","贽","赀" 2413 ,"赅","赆","赈","赉","赇","赍","赕","赙","觇","觊","觋","觌","觎","觏","觐","觑" 2414 ,"牮","犟","牝","牦","牯","牾","牿","犄","犋","犍","犏","犒","挈","挲","掰" 2415 ,"搿","擘","耄","毪","毳","毽","毵","毹","氅","氇","氆","氍","氕","氘","氙" 2416 ,"氚","氡","氩","氤","氪","氲","攵","敕","敫","牍","牒","牖","爰","虢","刖","肟" 2417 ,"肜","肓","肼","朊","肽","肱","肫","肭","肴","肷","胧","胨","胩","胪","胛","胂" 2418 ,"胄","胙","胍","胗","朐","胝","胫","胱","胴","胭","脍","脎","胲","胼","朕","脒" 2419 ,"豚","脶","脞","脬","脘","脲","腈","腌","腓","腴","腙","腚","腱","腠","腩","腼" 2420 ,"腽","腭","腧","塍","媵","膈","膂","膑","滕","膣","膪","臌","朦","臊","膻" 2421 ,"臁","膦","欤","欷","欹","歃","歆","歙","飑","飒","飓","飕","飙","飚","殳" 2422 ,"彀","毂","觳","斐","齑","斓","於","旆","旄","旃","旌","旎","旒","旖","炀","炜" 2423 ,"炖","炝","炻","烀","炷","炫","炱","烨","烊","焐","焓","焖","焯","焱","煳","煜" 2424 ,"煨","煅","煲","煊","煸","煺","熘","熳","熵","熨","熠","燠","燔","燧","燹","爝" 2425 ,"爨","灬","焘","煦","熹","戾","戽","扃","扈","扉","礻","祀","祆","祉","祛","祜" 2426 ,"祓","祚","祢","祗","祠","祯","祧","祺","禅","禊","禚","禧","禳","忑","忐" 2427 ,"怼","恝","恚","恧","恁","恙","恣","悫","愆","愍","慝","憩","憝","懋","懑" 2428 ,"戆","肀","聿","沓","泶","淼","矶","矸","砀","砉","砗","砘","砑","斫","砭","砜" 2429 ,"砝","砹","砺","砻","砟","砼","砥","砬","砣","砩","硎","硭","硖","硗","砦","硐" 2430 ,"硇","硌","硪","碛","碓","碚","碇","碜","碡","碣","碲","碹","碥","磔","磙","磉" 2431 ,"磬","磲","礅","磴","礓","礤","礞","礴","龛","黹","黻","黼","盱","眄","眍","盹" 2432 ,"眇","眈","眚","眢","眙","眭","眦","眵","眸","睐","睑","睇","睃","睚","睨" 2433 ,"睢","睥","睿","瞍","睽","瞀","瞌","瞑","瞟","瞠","瞰","瞵","瞽","町","畀" 2434 ,"畎","畋","畈","畛","畲","畹","疃","罘","罡","罟","詈","罨","罴","罱","罹","羁" 2435 ,"罾","盍","盥","蠲","钅","钆","钇","钋","钊","钌","钍","钏","钐","钔","钗","钕" 2436 ,"钚","钛","钜","钣","钤","钫","钪","钭","钬","钯","钰","钲","钴","钶","钷","钸" 2437 ,"钹","钺","钼","钽","钿","铄","铈","铉","铊","铋","铌","铍","铎","铐","铑","铒" 2438 ,"铕","铖","铗","铙","铘","铛","铞","铟","铠","铢","铤","铥","铧","铨","铪" 2439 ,"铩","铫","铮","铯","铳","铴","铵","铷","铹","铼","铽","铿","锃","锂","锆" 2440 ,"锇","锉","锊","锍","锎","锏","锒","锓","锔","锕","锖","锘","锛","锝","锞","锟" 2441 ,"锢","锪","锫","锩","锬","锱","锲","锴","锶","锷","锸","锼","锾","锿","镂","锵" 2442 ,"镄","镅","镆","镉","镌","镎","镏","镒","镓","镔","镖","镗","镘","镙","镛","镞" 2443 ,"镟","镝","镡","镢","镤","镥","镦","镧","镨","镩","镪","镫","镬","镯","镱","镲" 2444 ,"镳","锺","矧","矬","雉","秕","秭","秣","秫","稆","嵇","稃","稂","稞","稔" 2445 ,"稹","稷","穑","黏","馥","穰","皈","皎","皓","皙","皤","瓞","瓠","甬","鸠" 2446 ,"鸢","鸨","鸩","鸪","鸫","鸬","鸲","鸱","鸶","鸸","鸷","鸹","鸺","鸾","鹁","鹂" 2447 ,"鹄","鹆","鹇","鹈","鹉","鹋","鹌","鹎","鹑","鹕","鹗","鹚","鹛","鹜","鹞","鹣" 2448 ,"鹦","鹧","鹨","鹩","鹪","鹫","鹬","鹱","鹭","鹳","疒","疔","疖","疠","疝","疬" 2449 ,"疣","疳","疴","疸","痄","疱","疰","痃","痂","痖","痍","痣","痨","痦","痤","痫" 2450 ,"痧","瘃","痱","痼","痿","瘐","瘀","瘅","瘌","瘗","瘊","瘥","瘘","瘕","瘙" 2451 ,"瘛","瘼","瘢","瘠","癀","瘭","瘰","瘿","瘵","癃","瘾","瘳","癍","癞","癔" 2452 ,"癜","癖","癫","癯","翊","竦","穸","穹","窀","窆","窈","窕","窦","窠","窬","窨" 2453 ,"窭","窳","衤","衩","衲","衽","衿","袂","袢","裆","袷","袼","裉","裢","裎","裣" 2454 ,"裥","裱","褚","裼","裨","裾","裰","褡","褙","褓","褛","褊","褴","褫","褶","襁" 2455 ,"襦","襻","疋","胥","皲","皴","矜","耒","耔","耖","耜","耠","耢","耥","耦","耧" 2456 ,"耩","耨","耱","耋","耵","聃","聆","聍","聒","聩","聱","覃","顸","颀","颃" 2457 ,"颉","颌","颍","颏","颔","颚","颛","颞","颟","颡","颢","颥","颦","虍","虔" 2458 ,"虬","虮","虿","虺","虼","虻","蚨","蚍","蚋","蚬","蚝","蚧","蚣","蚪","蚓","蚩" 2459 ,"蚶","蛄","蚵","蛎","蚰","蚺","蚱","蚯","蛉","蛏","蚴","蛩","蛱","蛲","蛭","蛳" 2460 ,"蛐","蜓","蛞","蛴","蛟","蛘","蛑","蜃","蜇","蛸","蜈","蜊","蜍","蜉","蜣","蜻" 2461 ,"蜞","蜥","蜮","蜚","蜾","蝈","蜴","蜱","蜩","蜷","蜿","螂","蜢","蝽","蝾","蝻" 2462 ,"蝠","蝰","蝌","蝮","螋","蝓","蝣","蝼","蝤","蝙","蝥","螓","螯","螨","蟒" 2463 ,"蟆","螈","螅","螭","螗","螃","螫","蟥","螬","螵","螳","蟋","蟓","螽","蟑" 2464 ,"蟀","蟊","蟛","蟪","蟠","蟮","蠖","蠓","蟾","蠊","蠛","蠡","蠹","蠼","缶","罂" 2465 ,"罄","罅","舐","竺","竽","笈","笃","笄","笕","笊","笫","笏","筇","笸","笪","笙" 2466 ,"笮","笱","笠","笥","笤","笳","笾","笞","筘","筚","筅","筵","筌","筝","筠","筮" 2467 ,"筻","筢","筲","筱","箐","箦","箧","箸","箬","箝","箨","箅","箪","箜","箢","箫" 2468 ,"箴","篑","篁","篌","篝","篚","篥","篦","篪","簌","篾","篼","簏","簖","簋" 2469 ,"簟","簪","簦","簸","籁","籀","臾","舁","舂","舄","臬","衄","舡","舢","舣" 2470 ,"舭","舯","舨","舫","舸","舻","舳","舴","舾","艄","艉","艋","艏","艚","艟","艨" 2471 ,"衾","袅","袈","裘","裟","襞","羝","羟","羧","羯","羰","羲","籼","敉","粑","粝" 2472 ,"粜","粞","粢","粲","粼","粽","糁","糇","糌","糍","糈","糅","糗","糨","艮","暨" 2473 ,"羿","翎","翕","翥","翡","翦","翩","翮","翳","糸","絷","綦","綮","繇","纛","麸" 2474 ,"麴","赳","趄","趔","趑","趱","赧","赭","豇","豉","酊","酐","酎","酏","酤" 2475 ,"酢","酡","酰","酩","酯","酽","酾","酲","酴","酹","醌","醅","醐","醍","醑" 2476 ,"醢","醣","醪","醭","醮","醯","醵","醴","醺","豕","鹾","趸","跫","踅","蹙","蹩" 2477 ,"趵","趿","趼","趺","跄","跖","跗","跚","跞","跎","跏","跛","跆","跬","跷","跸" 2478 ,"跣","跹","跻","跤","踉","跽","踔","踝","踟","踬","踮","踣","踯","踺","蹀","踹" 2479 ,"踵","踽","踱","蹉","蹁","蹂","蹑","蹒","蹊","蹰","蹶","蹼","蹯","蹴","躅","躏" 2480 ,"躔","躐","躜","躞","豸","貂","貊","貅","貘","貔","斛","觖","觞","觚","觜" 2481 ,"觥","觫","觯","訾","謦","靓","雩","雳","雯","霆","霁","霈","霏","霎","霪" 2482 ,"霭","霰","霾","龀","龃","龅","龆","龇","龈","龉","龊","龌","黾","鼋","鼍","隹" 2483 ,"隼","隽","雎","雒","瞿","雠","銎","銮","鋈","錾","鍪","鏊","鎏","鐾","鑫","鱿" 2484 ,"鲂","鲅","鲆","鲇","鲈","稣","鲋","鲎","鲐","鲑","鲒","鲔","鲕","鲚","鲛","鲞" 2485 ,"鲟","鲠","鲡","鲢","鲣","鲥","鲦","鲧","鲨","鲩","鲫","鲭","鲮","鲰","鲱","鲲" 2486 ,"鲳","鲴","鲵","鲶","鲷","鲺","鲻","鲼","鲽","鳄","鳅","鳆","鳇","鳊","鳋" 2487 ,"鳌","鳍","鳎","鳏","鳐","鳓","鳔","鳕","鳗","鳘","鳙","鳜","鳝","鳟","鳢" 2488 ,"靼","鞅","鞑","鞒","鞔","鞯","鞫","鞣","鞲","鞴","骱","骰","骷","鹘","骶","骺" 2489 ,"骼","髁","髀","髅","髂","髋","髌","髑","魅","魃","魇","魉","魈","魍","魑","飨" 2490 ,"餍","餮","饕","饔","髟","髡","髦","髯","髫","髻","髭","髹","鬈","鬏","鬓","鬟" 2491 ,"鬣","麽","麾","縻","麂","麇","麈","麋","麒","鏖","麝","麟","黛","黜","黝","黠" 2492 ,"黟","黢","黩","黧","黥","黪","黯","鼢","鼬","鼯","鼹","鼷","鼽","鼾","齄" 2493 }; 2494 2495 /// <summary> 2496 /// 二级汉字对应拼音数组 2497 /// </summary> 2498 private static string[] otherPinYin = new string[] 2499 { 2500 "Chu","Ji","Wu","Gai","Nian","Sa","Pi","Gen","Cheng","Ge","Nao","E","Shu","Yu","Pie","Bi", 2501 "Tuo","Yao","Yao","Zhi","Di","Xin","Yin","Kui","Yu","Gao","Tao","Dian","Ji","Nai","Nie","Ji", 2502 "Qi","Mi","Bei","Se","Gu","Ze","She","Cuo","Yan","Jue","Si","Ye","Yan","Fang","Po","Gui", 2503 "Kui","Bian","Ze","Gua","You","Ce","Yi","Wen","Jing","Ku","Gui","Kai","La","Ji","Yan","Wan", 2504 "Kuai","Piao","Jue","Qiao","Huo","Yi","Tong","Wang","Dan","Ding","Zhang","Le","Sa","Yi","Mu","Ren", 2505 "Yu","Pi","Ya","Wa","Wu","Chang","Cang","Kang","Zhu","Ning","Ka","You","Yi","Gou","Tong","Tuo", 2506 "Ni","Ga","Ji","Er","You","Kua","Kan","Zhu","Yi","Tiao","Chai","Jiao","Nong","Mou","Chou","Yan", 2507 "Li","Qiu","Li","Yu","Ping","Yong","Si","Feng","Qian","Ruo","Pai","Zhuo","Shu","Luo","Wo","Bi", 2508 "Ti","Guan","Kong","Ju","Fen","Yan","Xie","Ji","Wei","Zong","Lou","Tang","Bin","Nuo","Chi","Xi", 2509 "Jing","Jian","Jiao","Jiu","Tong","Xuan","Dan","Tong","Tun","She","Qian","Zu","Yue","Cuan","Di","Xi", 2510 "Xun","Hong","Guo","Chan","Kui","Bao","Pu","Hong","Fu","Fu","Su","Si","Wen","Yan","Bo","Gun", 2511 "Mao","Xie","Luan","Pou","Bing","Ying","Luo","Lei","Liang","Hu","Lie","Xian","Song","Ping","Zhong","Ming", 2512 "Yan","Jie","Hong","Shan","Ou","Ju","Ne","Gu","He","Di","Zhao","Qu","Dai","Kuang","Lei","Gua", 2513 "Jie","Hui","Shen","Gou","Quan","Zheng","Hun","Xu","Qiao","Gao","Kuang","Ei","Zou","Zhuo","Wei","Yu", 2514 "Shen","Chan","Sui","Chen","Jian","Xue","Ye","E","Yu","Xuan","An","Di","Zi","Pian","Mo","Dang", 2515 "Su","Shi","Mi","Zhe","Jian","Zen","Qiao","Jue","Yan","Zhan","Chen","Dan","Jin","Zuo","Wu","Qian", 2516 "Jing","Ban","Yan","Zuo","Bei","Jing","Gai","Zhi","Nie","Zou","Chui","Pi","Wei","Huang","Wei","Xi", 2517 "Han","Qiong","Kuang","Mang","Wu","Fang","Bing","Pi","Bei","Ye","Di","Tai","Jia","Zhi","Zhu","Kuai", 2518 "Qie","Xun","Yun","Li","Ying","Gao","Xi","Fu","Pi","Tan","Yan","Juan","Yan","Yin","Zhang","Po", 2519 "Shan","Zou","Ling","Feng","Chu","Huan","Mai","Qu","Shao","He","Ge","Meng","Xu","Xie","Sou","Xie", 2520 "Jue","Jian","Qian","Dang","Chang","Si","Bian","Ben","Qiu","Ben","E","Fa","Shu","Ji","Yong","He", 2521 "Wei","Wu","Ge","Zhen","Kuang","Pi","Yi","Li","Qi","Ban","Gan","Long","Dian","Lu","Che","Di", 2522 "Tuo","Ni","Mu","Ao","Ya","Die","Dong","Kai","Shan","Shang","Nao","Gai","Yin","Cheng","Shi","Guo", 2523 "Xun","Lie","Yuan","Zhi","An","Yi","Pi","Nian","Peng","Tu","Sao","Dai","Ku","Die","Yin","Leng", 2524 "Hou","Ge","Yuan","Man","Yong","Liang","Chi","Xin","Pi","Yi","Cao","Jiao","Nai","Du","Qian","Ji", 2525 "Wan","Xiong","Qi","Xiang","Fu","Yuan","Yun","Fei","Ji","Li","E","Ju","Pi","Zhi","Rui","Xian", 2526 "Chang","Cong","Qin","Wu","Qian","Qi","Shan","Bian","Zhu","Kou","Yi","Mo","Gan","Pie","Long","Ba", 2527 "Mu","Ju","Ran","Qing","Chi","Fu","Ling","Niao","Yin","Mao","Ying","Qiong","Min","Tiao","Qian","Yi", 2528 "Rao","Bi","Zi","Ju","Tong","Hui","Zhu","Ting","Qiao","Fu","Ren","Xing","Quan","Hui","Xun","Ming", 2529 "Qi","Jiao","Chong","Jiang","Luo","Ying","Qian","Gen","Jin","Mai","Sun","Hong","Zhou","Kan","Bi","Shi", 2530 "Wo","You","E","Mei","You","Li","Tu","Xian","Fu","Sui","You","Di","Shen","Guan","Lang","Ying", 2531 "Chun","Jing","Qi","Xi","Song","Jin","Nai","Qi","Ba","Shu","Chang","Tie","Yu","Huan","Bi","Fu", 2532 "Tu","Dan","Cui","Yan","Zu","Dang","Jian","Wan","Ying","Gu","Han","Qia","Feng","Shen","Xiang","Wei", 2533 "Chan","Kai","Qi","Kui","Xi","E","Bao","Pa","Ting","Lou","Pai","Xuan","Jia","Zhen","Shi","Ru", 2534 "Mo","En","Bei","Weng","Hao","Ji","Li","Bang","Jian","Shuo","Lang","Ying","Yu","Su","Meng","Dou", 2535 "Xi","Lian","Cu","Lin","Qu","Kou","Xu","Liao","Hui","Xun","Jue","Rui","Zui","Ji","Meng","Fan", 2536 "Qi","Hong","Xie","Hong","Wei","Yi","Weng","Sou","Bi","Hao","Tai","Ru","Xun","Xian","Gao","Li", 2537 "Huo","Qu","Heng","Fan","Nie","Mi","Gong","Yi","Kuang","Lian","Da","Yi","Xi","Zang","Pao","You", 2538 "Liao","Ga","Gan","Ti","Men","Tuan","Chen","Fu","Pin","Niu","Jie","Jiao","Za","Yi","Lv","Jun", 2539 "Tian","Ye","Ai","Na","Ji","Guo","Bai","Ju","Pou","Lie","Qian","Guan","Die","Zha","Ya","Qin", 2540 "Yu","An","Xuan","Bing","Kui","Yuan","Shu","En","Chuai","Jian","Shuo","Zhan","Nuo","Sang","Luo","Ying", 2541 "Zhi","Han","Zhe","Xie","Lu","Zun","Cuan","Gan","Huan","Pi","Xing","Zhuo","Huo","Zuan","Nang","Yi", 2542 "Te","Dai","Shi","Bu","Chi","Ji","Kou","Dao","Le","Zha","A","Yao","Fu","Mu","Yi","Tai", 2543 "Li","E","Bi","Bei","Guo","Qin","Yin","Za","Ka","Ga","Gua","Ling","Dong","Ning","Duo","Nao", 2544 "You","Si","Kuang","Ji","Shen","Hui","Da","Lie","Yi","Xiao","Bi","Ci","Guang","Yue","Xiu","Yi", 2545 "Pai","Kuai","Duo","Ji","Mie","Mi","Zha","Nong","Gen","Mou","Mai","Chi","Lao","Geng","En","Zha", 2546 "Suo","Zao","Xi","Zuo","Ji","Feng","Ze","Nuo","Miao","Lin","Zhuan","Zhou","Tao","Hu","Cui","Sha", 2547 "Yo","Dan","Bo","Ding","Lang","Li","Shua","Chuo","Die","Da","Nan","Li","Kui","Jie","Yong","Kui", 2548 "Jiu","Sou","Yin","Chi","Jie","Lou","Ku","Wo","Hui","Qin","Ao","Su","Du","Ke","Nie","He", 2549 "Chen","Suo","Ge","A","En","Hao","Dia","Ai","Ai","Suo","Hei","Tong","Chi","Pei","Lei","Cao", 2550 "Piao","Qi","Ying","Beng","Sou","Di","Mi","Peng","Jue","Liao","Pu","Chuai","Jiao","O","Qin","Lu", 2551 "Ceng","Deng","Hao","Jin","Jue","Yi","Sai","Pi","Ru","Cha","Huo","Nang","Wei","Jian","Nan","Lun", 2552 "Hu","Ling","You","Yu","Qing","Yu","Huan","Wei","Zhi","Pei","Tang","Dao","Ze","Guo","Wei","Wo", 2553 "Man","Zhang","Fu","Fan","Ji","Qi","Qian","Qi","Qu","Ya","Xian","Ao","Cen","Lan","Ba","Hu", 2554 "Ke","Dong","Jia","Xiu","Dai","Gou","Mao","Min","Yi","Dong","Qiao","Xun","Zheng","Lao","Lai","Song", 2555 "Yan","Gu","Xiao","Guo","Kong","Jue","Rong","Yao","Wai","Zai","Wei","Yu","Cuo","Lou","Zi","Mei", 2556 "Sheng","Song","Ji","Zhang","Lin","Deng","Bin","Yi","Dian","Chi","Pang","Cu","Xun","Yang","Hou","Lai", 2557 "Xi","Chang","Huang","Yao","Zheng","Jiao","Qu","San","Fan","Qiu","An","Guang","Ma","Niu","Yun","Xia", 2558 "Pao","Fei","Rong","Kuai","Shou","Sun","Bi","Juan","Li","Yu","Xian","Yin","Suan","Yi","Guo","Luo", 2559 "Ni","She","Cu","Mi","Hu","Cha","Wei","Wei","Mei","Nao","Zhang","Jing","Jue","Liao","Xie","Xun", 2560 "Huan","Chuan","Huo","Sun","Yin","Dong","Shi","Tang","Tun","Xi","Ren","Yu","Chi","Yi","Xiang","Bo", 2561 "Yu","Hun","Zha","Sou","Mo","Xiu","Jin","San","Zhuan","Nang","Pi","Wu","Gui","Pao","Xiu","Xiang", 2562 "Tuo","An","Yu","Bi","Geng","Ao","Jin","Chan","Xie","Lin","Ying","Shu","Dao","Cun","Chan","Wu", 2563 "Zhi","Ou","Chong","Wu","Kai","Chang","Chuang","Song","Bian","Niu","Hu","Chu","Peng","Da","Yang","Zuo", 2564 "Ni","Fu","Chao","Yi","Yi","Tong","Yan","Ce","Kai","Xun","Ke","Yun","Bei","Song","Qian","Kui", 2565 "Kun","Yi","Ti","Quan","Qie","Xing","Fei","Chang","Wang","Chou","Hu","Cui","Yun","Kui","E","Leng", 2566 "Zhui","Qiao","Bi","Su","Qie","Yong","Jing","Qiao","Chong","Chu","Lin","Meng","Tian","Hui","Shuan","Yan", 2567 "Wei","Hong","Min","Kang","Ta","Lv","Kun","Jiu","Lang","Yu","Chang","Xi","Wen","Hun","E","Qu", 2568 "Que","He","Tian","Que","Kan","Jiang","Pan","Qiang","San","Qi","Si","Cha","Feng","Yuan","Mu","Mian", 2569 "Dun","Mi","Gu","Bian","Wen","Hang","Wei","Le","Gan","Shu","Long","Lu","Yang","Si","Duo","Ling", 2570 "Mao","Luo","Xuan","Pan","Duo","Hong","Min","Jing","Huan","Wei","Lie","Jia","Zhen","Yin","Hui","Zhu", 2571 "Ji","Xu","Hui","Tao","Xun","Jiang","Liu","Hu","Xun","Ru","Su","Wu","Lai","Wei","Zhuo","Juan", 2572 "Cen","Bang","Xi","Mei","Huan","Zhu","Qi","Xi","Song","Du","Zhuo","Pei","Mian","Gan","Fei","Cong", 2573 "Shen","Guan","Lu","Shuan","Xie","Yan","Mian","Qiu","Sou","Huang","Xu","Pen","Jian","Xuan","Wo","Mei", 2574 "Yan","Qin","Ke","She","Mang","Ying","Pu","Li","Ru","Ta","Hun","Bi","Xiu","Fu","Tang","Pang", 2575 "Ming","Huang","Ying","Xiao","Lan","Cao","Hu","Luo","Huan","Lian","Zhu","Yi","Lu","Xuan","Gan","Shu", 2576 "Si","Shan","Shao","Tong","Chan","Lai","Sui","Li","Dan","Chan","Lian","Ru","Pu","Bi","Hao","Zhuo", 2577 "Han","Xie","Ying","Yue","Fen","Hao","Ba","Bao","Gui","Dang","Mi","You","Chen","Ning","Jian","Qian", 2578 "Wu","Liao","Qian","Huan","Jian","Jian","Zou","Ya","Wu","Jiong","Ze","Yi","Er","Jia","Jing","Dai", 2579 "Hou","Pang","Bu","Li","Qiu","Xiao","Ti","Qun","Kui","Wei","Huan","Lu","Chuan","Huang","Qiu","Xia", 2580 "Ao","Gou","Ta","Liu","Xian","Lin","Ju","Xie","Miao","Sui","La","Ji","Hui","Tuan","Zhi","Kao", 2581 "Zhi","Ji","E","Chan","Xi","Ju","Chan","Jing","Nu","Mi","Fu","Bi","Yu","Che","Shuo","Fei", 2582 "Yan","Wu","Yu","Bi","Jin","Zi","Gui","Niu","Yu","Si","Da","Zhou","Shan","Qie","Ya","Rao", 2583 "Shu","Luan","Jiao","Pin","Cha","Li","Ping","Wa","Xian","Suo","Di","Wei","E","Jing","Biao","Jie", 2584 "Chang","Bi","Chan","Nu","Ao","Yuan","Ting","Wu","Gou","Mo","Pi","Ai","Pin","Chi","Li","Yan", 2585 "Qiang","Piao","Chang","Lei","Zhang","Xi","Shan","Bi","Niao","Mo","Shuang","Ga","Ga","Fu","Nu","Zi", 2586 "Jie","Jue","Bao","Zang","Si","Fu","Zou","Yi","Nu","Dai","Xiao","Hua","Pian","Li","Qi","Ke", 2587 "Zhui","Can","Zhi","Wu","Ao","Liu","Shan","Biao","Cong","Chan","Ji","Xiang","Jiao","Yu","Zhou","Ge", 2588 "Wan","Kuang","Yun","Pi","Shu","Gan","Xie","Fu","Zhou","Fu","Chu","Dai","Ku","Hang","Jiang","Geng", 2589 "Xiao","Ti","Ling","Qi","Fei","Shang","Gun","Duo","Shou","Liu","Quan","Wan","Zi","Ke","Xiang","Ti", 2590 "Miao","Hui","Si","Bian","Gou","Zhui","Min","Jin","Zhen","Ru","Gao","Li","Yi","Jian","Bin","Piao", 2591 "Man","Lei","Miao","Sao","Xie","Liao","Zeng","Jiang","Qian","Qiao","Huan","Zuan","Yao","Ji","Chuan","Zai", 2592 "Yong","Ding","Ji","Wei","Bin","Min","Jue","Ke","Long","Dian","Dai","Po","Min","Jia","Er","Gong", 2593 "Xu","Ya","Heng","Yao","Luo","Xi","Hui","Lian","Qi","Ying","Qi","Hu","Kun","Yan","Cong","Wan", 2594 "Chen","Ju","Mao","Yu","Yuan","Xia","Nao","Ai","Tang","Jin","Huang","Ying","Cui","Cong","Xuan","Zhang", 2595 "Pu","Can","Qu","Lu","Bi","Zan","Wen","Wei","Yun","Tao","Wu","Shao","Qi","Cha","Ma","Li", 2596 "Pi","Miao","Yao","Rui","Jian","Chu","Cheng","Cong","Xiao","Fang","Pa","Zhu","Nai","Zhi","Zhe","Long", 2597 "Jiu","Ping","Lu","Xia","Xiao","You","Zhi","Tuo","Zhi","Ling","Gou","Di","Li","Tuo","Cheng","Kao", 2598 "Lao","Ya","Rao","Zhi","Zhen","Guang","Qi","Ting","Gua","Jiu","Hua","Heng","Gui","Jie","Luan","Juan", 2599 "An","Xu","Fan","Gu","Fu","Jue","Zi","Suo","Ling","Chu","Fen","Du","Qian","Zhao","Luo","Chui", 2600 "Liang","Guo","Jian","Di","Ju","Cou","Zhen","Nan","Zha","Lian","Lan","Ji","Pin","Ju","Qiu","Duan", 2601 "Chui","Chen","Lv","Cha","Ju","Xuan","Mei","Ying","Zhen","Fei","Ta","Sun","Xie","Gao","Cui","Gao", 2602 "Shuo","Bin","Rong","Zhu","Xie","Jin","Qiang","Qi","Chu","Tang","Zhu","Hu","Gan","Yue","Qing","Tuo", 2603 "Jue","Qiao","Qin","Lu","Zun","Xi","Ju","Yuan","Lei","Yan","Lin","Bo","Cha","You","Ao","Mo", 2604 "Cu","Shang","Tian","Yun","Lian","Piao","Dan","Ji","Bin","Yi","Ren","E","Gu","Ke","Lu","Zhi", 2605 "Yi","Zhen","Hu","Li","Yao","Shi","Zhi","Quan","Lu","Zhe","Nian","Wang","Chuo","Zi","Cou","Lu", 2606 "Lin","Wei","Jian","Qiang","Jia","Ji","Ji","Kan","Deng","Gai","Jian","Zang","Ou","Ling","Bu","Beng", 2607 "Zeng","Pi","Po","Ga","La","Gan","Hao","Tan","Gao","Ze","Xin","Yun","Gui","He","Zan","Mao", 2608 "Yu","Chang","Ni","Qi","Sheng","Ye","Chao","Yan","Hui","Bu","Han","Gui","Xuan","Kui","Ai","Ming", 2609 "Tun","Xun","Yao","Xi","Nang","Ben","Shi","Kuang","Yi","Zhi","Zi","Gai","Jin","Zhen","Lai","Qiu", 2610 "Ji","Dan","Fu","Chan","Ji","Xi","Di","Yu","Gou","Jin","Qu","Jian","Jiang","Pin","Mao","Gu", 2611 "Wu","Gu","Ji","Ju","Jian","Pian","Kao","Qie","Suo","Bai","Ge","Bo","Mao","Mu","Cui","Jian", 2612 "San","Shu","Chang","Lu","Pu","Qu","Pie","Dao","Xian","Chuan","Dong","Ya","Yin","Ke","Yun","Fan", 2613 "Chi","Jiao","Du","Die","You","Yuan","Guo","Yue","Wo","Rong","Huang","Jing","Ruan","Tai","Gong","Zhun", 2614 "Na","Yao","Qian","Long","Dong","Ka","Lu","Jia","Shen","Zhou","Zuo","Gua","Zhen","Qu","Zhi","Jing", 2615 "Guang","Dong","Yan","Kuai","Sa","Hai","Pian","Zhen","Mi","Tun","Luo","Cuo","Pao","Wan","Niao","Jing", 2616 "Yan","Fei","Yu","Zong","Ding","Jian","Cou","Nan","Mian","Wa","E","Shu","Cheng","Ying","Ge","Lv", 2617 "Bin","Teng","Zhi","Chuai","Gu","Meng","Sao","Shan","Lian","Lin","Yu","Xi","Qi","Sha","Xin","Xi", 2618 "Biao","Sa","Ju","Sou","Biao","Biao","Shu","Gou","Gu","Hu","Fei","Ji","Lan","Yu","Pei","Mao", 2619 "Zhan","Jing","Ni","Liu","Yi","Yang","Wei","Dun","Qiang","Shi","Hu","Zhu","Xuan","Tai","Ye","Yang", 2620 "Wu","Han","Men","Chao","Yan","Hu","Yu","Wei","Duan","Bao","Xuan","Bian","Tui","Liu","Man","Shang", 2621 "Yun","Yi","Yu","Fan","Sui","Xian","Jue","Cuan","Huo","Tao","Xu","Xi","Li","Hu","Jiong","Hu", 2622 "Fei","Shi","Si","Xian","Zhi","Qu","Hu","Fu","Zuo","Mi","Zhi","Ci","Zhen","Tiao","Qi","Chan", 2623 "Xi","Zhuo","Xi","Rang","Te","Tan","Dui","Jia","Hui","Nv","Nin","Yang","Zi","Que","Qian","Min", 2624 "Te","Qi","Dui","Mao","Men","Gang","Yu","Yu","Ta","Xue","Miao","Ji","Gan","Dang","Hua","Che", 2625 "Dun","Ya","Zhuo","Bian","Feng","Fa","Ai","Li","Long","Zha","Tong","Di","La","Tuo","Fu","Xing", 2626 "Mang","Xia","Qiao","Zhai","Dong","Nao","Ge","Wo","Qi","Dui","Bei","Ding","Chen","Zhou","Jie","Di", 2627 "Xuan","Bian","Zhe","Gun","Sang","Qing","Qu","Dun","Deng","Jiang","Ca","Meng","Bo","Kan","Zhi","Fu", 2628 "Fu","Xu","Mian","Kou","Dun","Miao","Dan","Sheng","Yuan","Yi","Sui","Zi","Chi","Mou","Lai","Jian", 2629 "Di","Suo","Ya","Ni","Sui","Pi","Rui","Sou","Kui","Mao","Ke","Ming","Piao","Cheng","Kan","Lin", 2630 "Gu","Ding","Bi","Quan","Tian","Fan","Zhen","She","Wan","Tuan","Fu","Gang","Gu","Li","Yan","Pi", 2631 "Lan","Li","Ji","Zeng","He","Guan","Juan","Jin","Ga","Yi","Po","Zhao","Liao","Tu","Chuan","Shan", 2632 "Men","Chai","Nv","Bu","Tai","Ju","Ban","Qian","Fang","Kang","Dou","Huo","Ba","Yu","Zheng","Gu", 2633 "Ke","Po","Bu","Bo","Yue","Mu","Tan","Dian","Shuo","Shi","Xuan","Ta","Bi","Ni","Pi","Duo", 2634 "Kao","Lao","Er","You","Cheng","Jia","Nao","Ye","Cheng","Diao","Yin","Kai","Zhu","Ding","Diu","Hua", 2635 "Quan","Ha","Sha","Diao","Zheng","Se","Chong","Tang","An","Ru","Lao","Lai","Te","Keng","Zeng","Li", 2636 "Gao","E","Cuo","Lve","Liu","Kai","Jian","Lang","Qin","Ju","A","Qiang","Nuo","Ben","De","Ke", 2637 "Kun","Gu","Huo","Pei","Juan","Tan","Zi","Qie","Kai","Si","E","Cha","Sou","Huan","Ai","Lou", 2638 "Qiang","Fei","Mei","Mo","Ge","Juan","Na","Liu","Yi","Jia","Bin","Biao","Tang","Man","Luo","Yong", 2639 "Chuo","Xuan","Di","Tan","Jue","Pu","Lu","Dui","Lan","Pu","Cuan","Qiang","Deng","Huo","Zhuo","Yi", 2640 "Cha","Biao","Zhong","Shen","Cuo","Zhi","Bi","Zi","Mo","Shu","Lv","Ji","Fu","Lang","Ke","Ren", 2641 "Zhen","Ji","Se","Nian","Fu","Rang","Gui","Jiao","Hao","Xi","Po","Die","Hu","Yong","Jiu","Yuan", 2642 "Bao","Zhen","Gu","Dong","Lu","Qu","Chi","Si","Er","Zhi","Gua","Xiu","Luan","Bo","Li","Hu", 2643 "Yu","Xian","Ti","Wu","Miao","An","Bei","Chun","Hu","E","Ci","Mei","Wu","Yao","Jian","Ying", 2644 "Zhe","Liu","Liao","Jiao","Jiu","Yu","Hu","Lu","Guan","Bing","Ding","Jie","Li","Shan","Li","You", 2645 "Gan","Ke","Da","Zha","Pao","Zhu","Xuan","Jia","Ya","Yi","Zhi","Lao","Wu","Cuo","Xian","Sha", 2646 "Zhu","Fei","Gu","Wei","Yu","Yu","Dan","La","Yi","Hou","Chai","Lou","Jia","Sao","Chi","Mo", 2647 "Ban","Ji","Huang","Biao","Luo","Ying","Zhai","Long","Yin","Chou","Ban","Lai","Yi","Dian","Pi","Dian", 2648 "Qu","Yi","Song","Xi","Qiong","Zhun","Bian","Yao","Tiao","Dou","Ke","Yu","Xun","Ju","Yu","Yi", 2649 "Cha","Na","Ren","Jin","Mei","Pan","Dang","Jia","Ge","Ken","Lian","Cheng","Lian","Jian","Biao","Chu", 2650 "Ti","Bi","Ju","Duo","Da","Bei","Bao","Lv","Bian","Lan","Chi","Zhe","Qiang","Ru","Pan","Ya", 2651 "Xu","Jun","Cun","Jin","Lei","Zi","Chao","Si","Huo","Lao","Tang","Ou","Lou","Jiang","Nou","Mo", 2652 "Die","Ding","Dan","Ling","Ning","Guo","Kui","Ao","Qin","Han","Qi","Hang","Jie","He","Ying","Ke", 2653 "Han","E","Zhuan","Nie","Man","Sang","Hao","Ru","Pin","Hu","Qian","Qiu","Ji","Chai","Hui","Ge", 2654 "Meng","Fu","Pi","Rui","Xian","Hao","Jie","Gong","Dou","Yin","Chi","Han","Gu","Ke","Li","You", 2655 "Ran","Zha","Qiu","Ling","Cheng","You","Qiong","Jia","Nao","Zhi","Si","Qu","Ting","Kuo","Qi","Jiao", 2656 "Yang","Mou","Shen","Zhe","Shao","Wu","Li","Chu","Fu","Qiang","Qing","Qi","Xi","Yu","Fei","Guo", 2657 "Guo","Yi","Pi","Tiao","Quan","Wan","Lang","Meng","Chun","Rong","Nan","Fu","Kui","Ke","Fu","Sou", 2658 "Yu","You","Lou","You","Bian","Mou","Qin","Ao","Man","Mang","Ma","Yuan","Xi","Chi","Tang","Pang", 2659 "Shi","Huang","Cao","Piao","Tang","Xi","Xiang","Zhong","Zhang","Shuai","Mao","Peng","Hui","Pan","Shan","Huo", 2660 "Meng","Chan","Lian","Mie","Li","Du","Qu","Fou","Ying","Qing","Xia","Shi","Zhu","Yu","Ji","Du", 2661 "Ji","Jian","Zhao","Zi","Hu","Qiong","Po","Da","Sheng","Ze","Gou","Li","Si","Tiao","Jia","Bian", 2662 "Chi","Kou","Bi","Xian","Yan","Quan","Zheng","Jun","Shi","Gang","Pa","Shao","Xiao","Qing","Ze","Qie", 2663 "Zhu","Ruo","Qian","Tuo","Bi","Dan","Kong","Wan","Xiao","Zhen","Kui","Huang","Hou","Gou","Fei","Li", 2664 "Bi","Chi","Su","Mie","Dou","Lu","Duan","Gui","Dian","Zan","Deng","Bo","Lai","Zhou","Yu","Yu", 2665 "Chong","Xi","Nie","Nv","Chuan","Shan","Yi","Bi","Zhong","Ban","Fang","Ge","Lu","Zhu","Ze","Xi", 2666 "Shao","Wei","Meng","Shou","Cao","Chong","Meng","Qin","Niao","Jia","Qiu","Sha","Bi","Di","Qiang","Suo", 2667 "Jie","Tang","Xi","Xian","Mi","Ba","Li","Tiao","Xi","Zi","Can","Lin","Zong","San","Hou","Zan", 2668 "Ci","Xu","Rou","Qiu","Jiang","Gen","Ji","Yi","Ling","Xi","Zhu","Fei","Jian","Pian","He","Yi", 2669 "Jiao","Zhi","Qi","Qi","Yao","Dao","Fu","Qu","Jiu","Ju","Lie","Zi","Zan","Nan","Zhe","Jiang", 2670 "Chi","Ding","Gan","Zhou","Yi","Gu","Zuo","Tuo","Xian","Ming","Zhi","Yan","Shai","Cheng","Tu","Lei", 2671 "Kun","Pei","Hu","Ti","Xu","Hai","Tang","Lao","Bu","Jiao","Xi","Ju","Li","Xun","Shi","Cuo", 2672 "Dun","Qiong","Xue","Cu","Bie","Bo","Ta","Jian","Fu","Qiang","Zhi","Fu","Shan","Li","Tuo","Jia", 2673 "Bo","Tai","Kui","Qiao","Bi","Xian","Xian","Ji","Jiao","Liang","Ji","Chuo","Huai","Chi","Zhi","Dian", 2674 "Bo","Zhi","Jian","Die","Chuai","Zhong","Ju","Duo","Cuo","Pian","Rou","Nie","Pan","Qi","Chu","Jue", 2675 "Pu","Fan","Cu","Zhu","Lin","Chan","Lie","Zuan","Xie","Zhi","Diao","Mo","Xiu","Mo","Pi","Hu", 2676 "Jue","Shang","Gu","Zi","Gong","Su","Zhi","Zi","Qing","Liang","Yu","Li","Wen","Ting","Ji","Pei", 2677 "Fei","Sha","Yin","Ai","Xian","Mai","Chen","Ju","Bao","Tiao","Zi","Yin","Yu","Chuo","Wo","Mian", 2678 "Yuan","Tuo","Zhui","Sun","Jun","Ju","Luo","Qu","Chou","Qiong","Luan","Wu","Zan","Mou","Ao","Liu", 2679 "Bei","Xin","You","Fang","Ba","Ping","Nian","Lu","Su","Fu","Hou","Tai","Gui","Jie","Wei","Er", 2680 "Ji","Jiao","Xiang","Xun","Geng","Li","Lian","Jian","Shi","Tiao","Gun","Sha","Huan","Ji","Qing","Ling", 2681 "Zou","Fei","Kun","Chang","Gu","Ni","Nian","Diao","Shi","Zi","Fen","Die","E","Qiu","Fu","Huang", 2682 "Bian","Sao","Ao","Qi","Ta","Guan","Yao","Le","Biao","Xue","Man","Min","Yong","Gui","Shan","Zun", 2683 "Li","Da","Yang","Da","Qiao","Man","Jian","Ju","Rou","Gou","Bei","Jie","Tou","Ku","Gu","Di", 2684 "Hou","Ge","Ke","Bi","Lou","Qia","Kuan","Bin","Du","Mei","Ba","Yan","Liang","Xiao","Wang","Chi", 2685 "Xiang","Yan","Tie","Tao","Yong","Biao","Kun","Mao","Ran","Tiao","Ji","Zi","Xiu","Quan","Jiu","Bin", 2686 "Huan","Lie","Me","Hui","Mi","Ji","Jun","Zhu","Mi","Qi","Ao","She","Lin","Dai","Chu","You", 2687 "Xia","Yi","Qu","Du","Li","Qing","Can","An","Fen","You","Wu","Yan","Xi","Qiu","Han","Zha" 2688 }; 2689 #endregion 二级汉字 2690 #region 变量定义 2691 // GB2312-80 标准规范中第一个汉字的机内码.即"啊"的机内码 2692 private const int firstChCode = -20319; 2693 // GB2312-80 标准规范中最后一个汉字的机内码.即"齄"的机内码 2694 private const int lastChCode = -2050; 2695 // GB2312-80 标准规范中最后一个一级汉字的机内码.即"座"的机内码 2696 private const int lastOfOneLevelChCode = -10247; 2697 // 配置中文字符 2698 //static Regex regex = new Regex("[\u4e00-\u9fa5]$"); 2699 2700 #endregion 2701 #endregion 2702 2703 /// <summary> 2704 /// 取拼音第一个字段 2705 /// </summary> 2706 /// <param name="ch"></param> 2707 /// <returns></returns> 2708 public static String GetFirst(Char ch) 2709 { 2710 var rs = Get(ch); 2711 if (!String.IsNullOrEmpty(rs)) rs = rs.Substring(0, 1); 2712 2713 return rs; 2714 } 2715 2716 /// <summary> 2717 /// 取拼音第一个字段 2718 /// </summary> 2719 /// <param name="str"></param> 2720 /// <returns></returns> 2721 public static String GetFirst(String str) 2722 { 2723 if (String.IsNullOrEmpty(str)) return String.Empty; 2724 2725 var sb = new StringBuilder(str.Length + 1); 2726 var chs = str.ToCharArray(); 2727 2728 for (var i = 0; i < chs.Length; i++) 2729 { 2730 sb.Append(GetFirst(chs[i])); 2731 } 2732 2733 return sb.ToString(); 2734 } 2735 2736 /// <summary> 2737 /// 获取单字拼音 2738 /// </summary> 2739 /// <param name="ch"></param> 2740 /// <returns></returns> 2741 public static String Get(Char ch) 2742 { 2743 // 拉丁字符 2744 if (ch <= '\x00FF') return ch.ToString(); 2745 2746 // 标点符号、分隔符 2747 if (Char.IsPunctuation(ch) || Char.IsSeparator(ch)) return ch.ToString(); 2748 2749 // 非中文字符 2750 if (ch < '\x4E00' || ch > '\x9FA5') return ch.ToString(); 2751 2752 var arr = Encoding.GetEncoding("gb2312").GetBytes(ch.ToString()); 2753 //Encoding.Default默认在中文环境里虽是GB2312,但在多变的环境可能是其它 2754 //var arr = Encoding.Default.GetBytes(ch.ToString()); 2755 var chr = (Int16)arr[0] * 256 + (Int16)arr[1] - 65536; 2756 2757 //***// 单字符--英文或半角字符 2758 if (chr > 0 && chr < 160) return ch.ToString(); 2759 #region 中文字符处理 2760 2761 // 判断是否超过GB2312-80标准中的汉字范围 2762 if (chr > lastChCode || chr < firstChCode) 2763 { 2764 return ch.ToString();; 2765 } 2766 // 如果是在一级汉字中 2767 else if (chr <= lastOfOneLevelChCode) 2768 { 2769 // 将一级汉字分为12块,每块33个汉字. 2770 for (int aPos = 11; aPos >= 0; aPos--) 2771 { 2772 int aboutPos = aPos * 33; 2773 // 从最后的块开始扫描,如果机内码大于块的第一个机内码,说明在此块中 2774 if (chr >= pyValue[aboutPos]) 2775 { 2776 // Console.WriteLine("存在于第 " + aPos.ToString() + " 块,此块的第一个机内码是: " + pyValue[aPos * 33].ToString()); 2777 // 遍历块中的每个音节机内码,从最后的音节机内码开始扫描, 2778 // 如果音节内码小于机内码,则取此音节 2779 for (int i = aboutPos + 32; i >= aboutPos; i--) 2780 { 2781 if (pyValue[i] <= chr) 2782 { 2783 // Console.WriteLine("找到第一个小于要查找机内码的机内码: " + pyValue[i].ToString()); 2784 return pyName[i]; 2785 } 2786 } 2787 break; 2788 } 2789 } 2790 } 2791 // 如果是在二级汉字中 2792 else 2793 { 2794 int pos = Array.IndexOf(otherChinese, ch.ToString()); 2795 if (pos != decimal.MinusOne) 2796 { 2797 return otherPinYin[pos]; 2798 } 2799 } 2800 #endregion 中文字符处理 2801 2802 //if (chr < -20319 || chr > -10247) { // 不知道的字符 2803 // return null; 2804 2805 //for (var i = pyValue.Length - 1; i >= 0; i--) 2806 //{ 2807 // if (pyValue[i] <= chr) return pyName[i];//这只能对应数组已经定义的 2808 //} 2809 2810 return String.Empty; 2811 } 2812 2813 /// <summary> 2814 /// 把汉字转换成拼音(全拼) 2815 /// </summary> 2816 /// <param name="str">汉字字符串</param> 2817 /// <returns>转换后的拼音(全拼)字符串</returns> 2818 public static String GetPinYin(String str) 2819 { 2820 if (String.IsNullOrEmpty(str)) return String.Empty; 2821 2822 var sb = new StringBuilder(str.Length * 10); 2823 var chs = str.ToCharArray(); 2824 2825 for (var j = 0; j < chs.Length; j++) 2826 { 2827 sb.Append(Get(chs[j])); 2828 } 2829 2830 return sb.ToString(); 2831 } 2832 #endregion 2833 2834 #region 获取网页的HTML内容 2835 // 获取网页的HTML内容,指定Encoding 2836 public static string GetHtml(string url, Encoding encoding) 2837 { 2838 byte[] buf = new WebClient().DownloadData(url); 2839 if (encoding != null) return encoding.GetString(buf); 2840 string html = Encoding.UTF8.GetString(buf); 2841 encoding = GetEncoding(html); 2842 if (encoding == null || encoding == Encoding.UTF8) return html; 2843 return encoding.GetString(buf); 2844 } 2845 // 根据网页的HTML内容提取网页的Encoding 2846 public static Encoding GetEncoding(string html) 2847 { 2848 string pattern = @"(?i)\bcharset=(?<charset>[-a-zA-Z_0-9]+)"; 2849 string charset = Regex.Match(html, pattern).Groups["charset"].Value; 2850 try { return Encoding.GetEncoding(charset); } 2851 catch (ArgumentException) { return null; } 2852 } 2853 #endregion 2854 } 2855 }View Code