I have a file which extension is .b3c i want to know if it's encoded in ASCII or EBCDIC using java jow can I achieve that please.
Help is needed.
Thanks
I have a file which extension is .b3c i want to know if it's encoded in ASCII or EBCDIC using java jow can I achieve that please.
Help is needed.
Thanks
Copyright © 2021 Jogjafile Inc.
Assuming the text file contains multiple lines of text, check for the newline character.
In ASCII, lines end with an
LF
/\n
/0x0a
. Sure, on Windows there's also aCR
, but we can ignore that part.In EBCDIC, lines end with an
NL
/\025
/0x15
.ASCII text files will not contain a
0x15
/NAK
, and EBCDIC text files will not contain a0x0a
/SMM
, so look for both:If only one of them is found, you know the character set.
If both are found, the file is a binary file, and not a text file, so reject the file.
If neither is found, the file could have just one line of text, in which case further analysis might be needed. Hopefully that won't be the case for here, so the simple test done so far should be enough.