From 2706b9d232ed086fcffef566c1174b0ef51ae803 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Thu, 11 Jul 2024 17:49:50 +0300 Subject: [PATCH] fix hexa and binary print for bytes in sc_print! --- framework/base/src/formatter/formatter_impl_bytes.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/framework/base/src/formatter/formatter_impl_bytes.rs b/framework/base/src/formatter/formatter_impl_bytes.rs index 6fb525bb86..ca3f2f0b41 100644 --- a/framework/base/src/formatter/formatter_impl_bytes.rs +++ b/framework/base/src/formatter/formatter_impl_bytes.rs @@ -1,4 +1,7 @@ -use super::{FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex}; +use super::{ + hex_util::{byte_to_binary_digits, encode_bytes_as_hex}, + FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex, +}; impl SCDisplay for &[u8] { fn fmt(&self, f: &mut F) { @@ -8,12 +11,14 @@ impl SCDisplay for &[u8] { impl SCLowerHex for &[u8] { fn fmt(&self, f: &mut F) { - f.append_bytes(self); + f.append_bytes(encode_bytes_as_hex(self).as_bytes()); } } impl SCBinary for &[u8] { fn fmt(&self, f: &mut F) { - f.append_bytes(self); + for b in self.iter() { + f.append_bytes(&byte_to_binary_digits(*b)); + } } }