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
- +0..+9 →
- EBCDIC last-digit zone:
- Positive →
0xC - Negative →
0xD - Preferred-zero policy (EBCDIC) →
0xFfor zero regardless of sign
- Positive →
Enums§
- Zero
Sign Policy - 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
trueifbyteis a recognised EBCDIC overpunch zone byte.