/// <summary> /// 删除字符串中的一组标记 /// </summary> /// <param name="str"></param> /// <param name="tagA"></param> /// <param name="isContent"></param> /// <returns></returns> public static string DelTagArray(string str, string tagA, bool isContent) { string[] source = tagA.Split(new char[] { ',' }); return(source.Aggregate(str, (string current, string sr1) => MdStringHelper.DelTag(current, sr1, isContent))); }
/// <summary> /// 转换一个字符,输入如"Π"中的"03a0" /// </summary> /// <param name="unicodeSingle"></param> /// <returns></returns> public static string ConvertSingle(string unicodeSingle) { if (unicodeSingle.Length != 4) { return(null); } Encoding unicode = Encoding.Unicode; byte[] array = new byte[2]; byte[] array2 = array; for (int i = 0; i < 4; i++) { switch (i) { case 0: { byte[] expr_49_cp_0 = array2; int expr_49_cp_1 = 1; expr_49_cp_0[expr_49_cp_1] += (byte)(MdStringHelper.GetByte(unicodeSingle[i]) * 16); break; } case 1: { byte[] expr_6F_cp_0 = array2; int expr_6F_cp_1 = 1; expr_6F_cp_0[expr_6F_cp_1] += (byte)MdStringHelper.GetByte(unicodeSingle[i]); break; } case 2: { byte[] expr_92_cp_0 = array2; int expr_92_cp_1 = 0; expr_92_cp_0[expr_92_cp_1] += (byte)(MdStringHelper.GetByte(unicodeSingle[i]) * 16); break; } case 3: { byte[] expr_B8_cp_0 = array2; int expr_B8_cp_1 = 0; expr_B8_cp_0[expr_B8_cp_1] += (byte)MdStringHelper.GetByte(unicodeSingle[i]); break; } } } char[] array3 = new char[unicode.GetCharCount(array2, 0, array2.Length)]; unicode.GetChars(array2, 0, array2.Length, array3, 0); return(new string(array3)); }
/// <summary> /// unicode编码转换成GB2312汉字 /// </summary> /// <param name="str"></param> /// <returns></returns> public static string UtoGB(string str) { string[] array = str.Replace("\\", "").Split(new char[] { 'u' }); byte[] array2 = new byte[array.Length - 1]; for (int i = 1; i < array.Length; i++) { array2[i - 1] = Convert.ToByte(MdStringHelper.Convert2Hex(array[i])); } char[] chars = Encoding.GetEncoding("GB2312").GetChars(array2); string text = ""; for (int j = 0; j < chars.Length; j++) { text += chars[j].ToString(); } return(text); }
/// <summary> /// 在前面补0 /// </summary> /// <param name="sheep"></param> /// <param name="length"></param> /// <returns></returns> public static string AddZero(int sheep, int length) { return(MdStringHelper.AddZero(sheep.ToString(), length)); }
public static string TranslateToHtmlString(string str, int num) { string letter = MdStringHelper.GetLetter(str, num, false); return(MdStringHelper.StringToHtml(letter)); }
/// <summary> /// 截取长度并转换为HTML /// </summary> /// <param name="str"></param> /// <param name="num"></param> /// <returns></returns> public static string AcquireAssignString(string str, int num) { string letter = MdStringHelper.GetLetter(str, num, false); return(MdStringHelper.StringToHtml(letter)); }