1 year ago

#315788

test-img

Sahib Yar

Remove formatting bytes from Hex escaped ebcdic to UTF using java

I need to covert following EBCDIC to UTF-8 (if not ascii) using only Java. I don't want to use JTOpen and my solution is inspired by this answer

var infile = new File("file_path/filename.ebcdic");
try (var bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(infile),"CP037"))) 
{
    System.out.println(bufferedReader.lines().collect(Collectors.joining("\n")));
}

This is working fine for

sample-customer-data.ebcdic

but not for

English.ebcdic

I actually want to remove formatting Bytes as well for example

I need

Shah           Priya   Berlin              Berlin           MH00002
Schulz         Tomasz  Malmˆ               Scania           MH00001
Smith          Mike    Ames                Iowa             MH00011
Sanchez        Maria   Bogot·              D.C.             MH00041
Sasthi         Gayatri Bangalore           Karnataka        MH00045

instead of

CsBhBaBh           CpBrBiByBa   CbBeBrBlBiBn              CbBeBrBlBiBn           CmChC^C^C^C^C¥CsBcBhBuBlBz         CtBoBmBaBsBz  CmBaBlBmCð               CsBcBaBnBiBa           CmChC^C^C^C^C£CsBmBiBtBh          CmBiBkBe    CaBmBeBs                CiBoBwBa             CmChC^C^C^C£C£CsBaBnBcBhBeBz        CmBaBrBiBa   CbBoBgBoBtá              Cd.Cc.             CmChC^C^C^C©C£CsBaBsBtBhBi         CgBaByBaBtBrBi CbBaBnBgBaBlBoBrBe           CkBaBrBnBaBtBaBkBa        CmChC^C^C^C©C§

Edit 1:

Code updated as per comments suggestions.

java

utf-8

ebcdic

0 Answers

Your Answer

Accepted video resources