@@ -99,7 +99,7 @@ string bufferToHexDump(const(ubyte)[] buff, ulong length)
9999 {
100100 // From the buffer create the hex and char version.
101101 string byteAsHex = format(" %02x" , buff[idx- 1 ]);
102- char byteAsChar = to! char (isPrintable(buff[idx- 1 ]) ? toLower( buff[idx- 1 ]) : ' .' );
102+ char byteAsChar = to! char (isPrintable(buff[idx- 1 ]) ? buff[idx- 1 ] : ' .' );
103103
104104 lhs ~= " " ~ byteAsHex;
105105 rhs ~= byteAsChar;
@@ -123,3 +123,23 @@ string bufferToHexDump(const(ubyte)[] buff, ulong length)
123123
124124 return prettyBuffer;
125125}
126+
127+
128+ unittest
129+ {
130+ import std.stdio ;
131+ ubyte [] bufferHello = [0x10 , 0xFE , ' h' , ' e' , ' L' , ' L' , ' o' , ' .' ];
132+ assert (" 000000: 10 fe 68 65 4c 4c 6f 2e |..heLLo.|\n "
133+ == bufferToHexDump(bufferHello, bufferHello.length));
134+
135+ ubyte [] bufferTwoLines = [
136+ 0x00 , 0x19 , ' T' , ' h' , ' i' , ' s' , ' ' , ' i' ,
137+ 0x10 , 0xFE , ' s' , ' ' , ' T' , ' W' , ' O' , ' ' ,
138+ 0x10 , 0xFE , ' L' , ' i' , ' n' , ' e' , ' s' , ' .' ,
139+ 0x10 , 0xFE , ' ' , ' P' , ' a' , ' s' , ' s' , ' !' ];
140+ assert (
141+ " 000000: 00 19 54 68 69 73 20 69 10 fe 73 20 54 57 4f 20 |..This i..s TWO |\n " ~
142+ " 000010: 10 fe 4c 69 6e 65 73 2e 10 fe 20 50 61 73 73 21 |..Lines... Pass!|\n "
143+ == bufferToHexDump(bufferTwoLines, bufferTwoLines.length));
144+ }
145+
0 commit comments