16진수 문자열에 대한 변환을 수행하는 Helper Class 입니다.
Example #1
0
        public void CanConvertToHexStringAndReverse()
        {
            var hexString = HexTextTool.GetHexStringFromBytes(HexBytes);
            var hexBytes  = HexTextTool.GetBytesFromHexString(hexString);

            Assert.AreEqual(hexBytes, HexBytes);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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);
        }