Converting user-supplied strings/text to EBCDIC hexadecimal characters

See also this discussion on discourse, which provided a simple conversion function: Decoding EBCDIC array to string - #3 by stevengj

You can easily modify it to convert in other direction. Using the ebcdic_table defined in that post, do:

const ebcdic_inv_table = Dict(c => UInt8(b-1) for (b,c) in pairs(ebcdic_table))

string_to_ebcdic(s::String) = [ebcdic_inv_table[c] for c in s]
2 Likes