Skip to content

Units of measurement of bytes? #44

@ErichDonGubler

Description

@ErichDonGubler
Unit Implemented? Description Examples Suggested implementation
Decimal [x] A decimal integer, which is equivalent to specifying a single byte unit for the count. 23, 1024 u64::from_str(...)
Hex [x] Implemented in #45. A hexadecimal integer. Specified with a leading 0x. 0x17, 0x100 u64::from_str_radix(...)
Blocks [ ] A single block, which is by default 512 bytes but configurable via config flag. -b 512 -n 1block

N.B: one cannot use a block unit to define the block size.
Add a flag to optionally define block size, then check for a trailing block when parsing numbers. Multiply by block size.
Bytes [ ] A byte size familiar to most IT professionals. Specified by B at the end of the count, and can include an optional magnitudinal spec like kilobytes (K) or megabytes (M).
  • 23B: 23 bytes
  • 9KB: 9 kilobytes
Implement a regex of the form (?P<count>\d+)(?P<magnitude_unit>[KM]?)B.

Other open questions

  • Should the block unit, which might be controversial, be scoped into another issue?
  • Should a single leading - or + sign be supported?
    • Not sure how + is useful -- xxd's manual states that for the -s option + is useful only for stdin. Not sure what that means, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions