class

CrystalIso8583::Shared::Codec::Configurable

Inherits CrystalIso8583::Shared::Codec < Reference < Object


Configurable codec — independently selects the wire encoding used for the MTI, variable-length prefixes, numeric (N) field data, and alphanumeric (AN/ANS) field data. Useful for real-world networks (e.g. VisaNet BASE I) that mix encodings: BCD-packed MTI and numeric fields, raw binary length prefixes, and EBCDIC text fields.

Binary (B) field data is always treated as raw bytes, matching the other codecs. Binary length prefixes use a fixed byte width (binary_length_byte_size, default 1) for both LLVAR and LLLVAR fields, since real networks typically use a single byte for both rather than scaling the prefix width with the nominal digit count.

Track 2 (Z) field data follows numeric_encoding when it's BCD — packed via the Track 2 nibble mapping (digits, '=' separator, 'F' pad nibble) rather than plain digit BCD — since real networks BCD-pack Track 2 the same way they BCD-pack numeric fields. Otherwise it falls back to text_encoding, same as AN/ANS.

Constructors

new(mti_encoding : MtiEncoding = MtiEncoding::ASCII, length_encoding : LengthEncoding = LengthEncoding::ASCII, numeric_encoding : NumericEncoding = NumericEncoding::ASCII, text_encoding : TextEncoding = TextEncoding::ASCII, binary_length_byte_size : Int32 = 1)
Source

Instance methods

decode_field(bytes : Bytes, data_type : DataType, length : Int32) : String

Decode raw field bytes into a String. length is the logical field length (number of characters/digits), not the byte count. Binary fields (DataType::B) are returned as lowercase hex strings.

Source
decode_length(bytes : Bytes, digits : Int32) : Int32
Source
decode_mti(bytes : Bytes) : MTI
Source
decode_string(bytes : Bytes) : String
Source
encode_field(str : String, data_type : DataType) : Bytes

Encode a field value string using the codec rules for the given data type.

Source
encode_length(length : Int32, digits : Int32) : Bytes
Source
encode_mti(mti : MTI) : Bytes
Source
encode_string(str : String) : Bytes
Source
field_byte_size(length : Int32, data_type : DataType) : Int32

Number of wire bytes occupied by length field-units of data_type.

Source
length_byte_size(digits : Int32) : Int32

Number of bytes used by a variable-length prefix with digits digit positions.

Source
mti_byte_size

Number of bytes used by the MTI in this codec.

Source