Skip to main content

Crate copybook_overpunch

Crate copybook_overpunch 

Source
Expand description

Zoned decimal overpunch encoding and decoding.

This module provides centralized mapping for zoned decimal overpunch characters across different codepages (ASCII and EBCDIC variants).

Overpunch encoding combines the last digit with sign information:

  • ASCII: uses letters A-I for positive digits 1-9, J-R for negative digits 1-9
  • EBCDIC: uses zone nibbles 0xC (positive) and 0xD (negative)

Use encode_overpunch_byte and decode_overpunch_byte for single-byte conversion, or the lower-level zone helpers for EBCDIC-specific work.

§Overpunch rules (cheatsheet)

  • ASCII last-digit:
    • +0..+9 → {', A..I
    • -0..-9 → '}', J..R
  • EBCDIC last-digit zone:
    • Positive → 0xC
    • Negative → 0xD
    • Preferred-zero policy (EBCDIC) → 0xF for zero regardless of sign

Enums§

ZeroSignPolicy
Policy for the sign zone nibble when the numeric value is exactly zero.

Functions§

decode_ebcdic_overpunch_zone
Decode an EBCDIC overpunch zone byte into its sign and digit.
decode_overpunch_byte
Decode overpunch byte to extract digit and sign information
encode_ebcdic_overpunch_zone
Encode a sign and digit into an EBCDIC overpunch zone byte.
encode_overpunch_byte
Encode overpunch byte for the given digit, sign, and codepage
get_all_valid_overpunch_bytes
Returns every EBCDIC byte value that is a valid overpunch zone.
is_valid_overpunch
Returns true if byte is a recognised EBCDIC overpunch zone byte.