Skip to main content

format_hex_row

Function format_hex_row 

Source
pub fn format_hex_row(
    offset: usize,
    bytes: &[u8],
    bytes_per_group: usize,
) -> String
Expand description

Format one row of a hex dump.

Layout: <8-hex-digit offset>: <hex bytes grouped by bytes_per_group> <16-char ASCII gutter>. bytes_per_group must be one of 1, 2, 4, 8, 16 — corresponding to 2, 4, 8, 16, or 32 hex characters per group (16 = the whole row as a single group, no spacing between hex pairs).

When bytes.len() < 16, the hex portion is right-padded with spaces so the ASCII gutter remains column-aligned with full rows.

Offsets larger than 0xFFFFFFFF still render with at least 8 hex digits (the format width is a minimum, not a max).

Non-printable bytes (outside 0x20..=0x7E) render as . in the ASCII gutter.