I have the information, that a PIC S9(4)
field is encoded with comp-3. I also have a data file which contains data (in my case about a customer). When I open the data file using notepad++, it show's me chars like "DLE", "BEL" or "NUL", which leads me to this table.
First off, can you explay to me, what "comp-3" does? And how do I convert it back into a human readable format / data using c# for example (having both files as an input)?
in Comp-3 format
value comp-3 (hex)
123 x'123c'
-123 x'123d'
There are a lot existing questions https://stackoverflow.com/search?q=%22comp-3%22+cobol
If this is a mainframe file and has been converted to ASCII; it will not be use-able !!!. The 2nd answer in COBOL COMP-3 number format issue gives a good example of corruption of a Comp-3 when doing a ascii conversion.
If it is from the mainframe, The problems you face:
The best option is to do the conversion on the mainframe / Cobol and transfer a Text file.
Alternatively There are projects like coboltocsv which will convert a Cobol file to Csv using a Cobol Copybook.
As far as converting comp-3 that is easy enough. There are 2 approaches
Convert the Hex to a Hex-String (i.e. convert x'123c' --> "123C) and check the last sign character. See COMP-3 data unpacking in Java (Embedded in Pentaho)
Break the field into a series of nybles