format unknown values as HEX and ASCII when possible v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 17 Jul 2021 20:38:03 +0200
branchv_0
changeset 34 c15dc8762bdb
parent 33 13aa7280ac7b
child 35 bf2c546f49d1
format unknown values as HEX and ASCII when possible
src/lib/BasicASN1Reader.h
--- a/src/lib/BasicASN1Reader.h	Sat Jul 17 18:58:22 2021 +0200
+++ b/src/lib/BasicASN1Reader.h	Sat Jul 17 20:38:03 2021 +0200
@@ -258,13 +258,17 @@
 			// TODO: recover transaction?
 
 			std::stringstream description;
-			description << "value:"
+			description << "UNKNOWN:"
 					<< " tag = " << typeHeader.tag
 					<< " tagClass = " << (int) typeHeader.tagClass
 					<< " pc = " << (int) typeHeader.pc
 					<< " length = " << typeHeader.length
-					<< " definite = " << (typeHeader.definiteLength ? "true" : "false");
-
+					<< " definite = " << (typeHeader.definiteLength ? "true" : "false")
+					<< " hex = ";
+			description << std::hex << std::setfill('0');
+			for (uint8_t b : temp) description << std::setw(2) << (int) b;
+			description << " ascii = ";
+			for (uint8_t b : temp) description << (b >= 32 && b < 127 ? (char) b : '.');
 			// TODO: special event for unparsed? (instead of a text string)
 			handlers->writeTextString(typeHeader, description.str());
 		}