/// <summary> /// Constructs an EbcdicReader. /// </summary> /// <param name="inputStream">the stream to read the data from</param> /// <param name="fileFormat">the copybook to use for decoding records</param> /// <param name="hasRdw">true if records have a record descriptor word (RDW)</param> public EbcdicReader(BufferedStream inputStream, FileFormat fileFormat, bool hasRdw) { _stream = inputStream; _fileFormat = fileFormat; _decoder = new EbcdicDecoder(fileFormat.Charset); _recordFormatMap = new RecordFormatMap(fileFormat); _hasRdw = hasRdw; }
public void EbcdicTestsTest() { FieldFormat binary = new FieldFormat { Decimal = 0, Size = "6", Type = "B" }; EbcdicEncoder encoder = new EbcdicEncoder("ascii"); EbcdicDecoder decoder = new EbcdicDecoder("ascii"); decimal value1 = -1937m; decimal value2 = 1937m; Assert.AreEqual(value1, decoder.Decode(encoder.Encode(value1, binary), binary)); Assert.AreEqual(value2, decoder.Decode(encoder.Encode(value2, binary), binary)); }
/// <summary> /// Gets a value from a record. /// </summary> /// <param name="record">the record to get the value from</param> /// <returns>the read value</returns> public override decimal Get(byte[] record) { var value = Encoding.GetString(record, Start, Length).Trim(); return(value == string.Empty ? decimal.Zero : EbcdicDecoder.ParseZoned(value)); }
public void Before() { _decoder = new EbcdicDecoder(Encoding.ASCII); }
/// <summary> /// Gets a value from a record. /// </summary> /// <param name="record">the record to get the value from</param> /// <returns>the read value</returns> public override decimal Get(byte[] record) { return(EbcdicDecoder.ParsePacked(record, Start, Start + Length)); }