ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Add BINARY Clause Encoding Mechanism to Copybook #6886

Closed DimuthuMadushan closed 2 months ago

DimuthuMadushan commented 3 months ago

Description:

$subject

The BINARY fields use a different encoding mechanism compared to the standard fields. The following resource that explains the encoding steps. http://www.simotime.com/databn01.htm

MohamedSabthar commented 2 months ago

With this support we need to add the following API in copybook:Converter class

    public enum Encoding {
        ASCII,
        EBCDIC
    }

    private isolated function toBytes(typedesc<record {}> t, string? targetRecordName = (),
        Encoding encoding = ASCII) returns byte[]|Error {
        // ...
    }

    private isolated function fromBytes(byte[] bytes, string? targetRecordName = (),
        Encoding encoding = ASCII,  typedesc<record {}> t = <>) returns t|Error {
        // ...
    }

based on the encoding functions mentioned here can be called internally to handle the conversion: https://github.com/ballerina-platform/ballerina-library/issues/6892