public void CanConvertToHexStringAndReverse() { var hexString = HexTextTool.GetHexStringFromBytes(HexBytes); var hexBytes = HexTextTool.GetBytesFromHexString(hexString); Assert.AreEqual(hexBytes, HexBytes); }
/// <summary> /// 지정한 char 의 unicode string을 <paramref name="writer"/>에 쓴다. /// </summary> /// <param name="writer"></param> /// <param name="c"></param> public static void WriteCharAsUnicode(TextWriter writer, char c) { writer.ShouldNotBeNull("writer"); var h1 = HexTextTool.IntToHex((c >> 12) & '\x000f'); var h2 = HexTextTool.IntToHex((c >> 8) & '\x000f'); var h3 = HexTextTool.IntToHex((c >> 4) & '\x000f'); var h4 = HexTextTool.IntToHex(c & '\x000f'); writer.Write('\\'); writer.Write('u'); writer.Write(h1); writer.Write(h2); writer.Write(h3); writer.Write(h4); }
public void CanHexDumpString() { var dumpString = HexTextTool.GetHexDumpString(HexBytes); Assert.IsNotEmpty(dumpString); var dumpString2 = HexTextTool.GetHexDumpString(StringTool.ToStream(OriginalString, Encoding.UTF8)); Assert.IsNotEmpty(dumpString2); //Console.WriteLine(dumpString); //Console.WriteLine(); //Console.WriteLine(dumpString2); Assert.AreEqual(dumpString, dumpString2); }