pub fn should_encode_as_blank_when_zero(value: &str, bwz_encode: bool) -> boolExpand description
Determine whether a value should be encoded as all spaces under the
COBOL BLANK WHEN ZERO clause.
Returns true when bwz_encode is enabled and the string value
represents zero (including decimal zeros such as "0.00"). Callers
use this check before encoding to decide whether to emit a
space-filled field instead of the normal numeric encoding.
§Arguments
value- String representation of the numeric value to testbwz_encode- Whether the BLANK WHEN ZERO clause is active for this field
§Returns
true if the field should be encoded as all spaces; false otherwise.
§Examples
use copybook_codec::numeric::should_encode_as_blank_when_zero;
assert!(should_encode_as_blank_when_zero("0", true));
assert!(should_encode_as_blank_when_zero("0.00", true));
assert!(!should_encode_as_blank_when_zero("42", true));
assert!(!should_encode_as_blank_when_zero("0", false)); // BWZ disabled§See Also
encode_zoned_decimal_with_bwz- Uses this function to apply the BWZ policy