File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ string BytesUtils::formatBytes(
263263 os << formatHexString (_bytes);
264264 break ;
265265 case ABIType::String:
266- os << formatString (_bytes);
266+ os << formatString (_bytes, _bytes. size () - countRightPaddedZeros (_bytes) );
267267 break ;
268268 case ABIType::Failure:
269269 break ;
@@ -311,3 +311,12 @@ string BytesUtils::formatBytesRange(
311311 return os.str ();
312312}
313313
314+ size_t BytesUtils::countRightPaddedZeros (bytes const & _bytes)
315+ {
316+ return find_if (
317+ _bytes.rbegin (),
318+ _bytes.rend (),
319+ [](uint8_t b) { return b != ' \0 ' ; }
320+ ) - _bytes.rbegin ();
321+ }
322+
Original file line number Diff line number Diff line change @@ -122,6 +122,10 @@ class BytesUtils
122122 ParameterList const & _parameters,
123123 bool _highlight
124124 );
125+
126+ // / Count the number of zeros between the last non-zero byte and the end of
127+ // / \param _bytes.
128+ static size_t countRightPaddedZeros (bytes const & _bytes);
125129};
126130
127131}
You can’t perform that action at this time.
0 commit comments