Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading an untagged file <= 8 bytes in size causes output encoding differences #84

Open
chrishodgins opened this issue Apr 2, 2024 · 2 comments

Comments

@chrishodgins
Copy link

With the following perl program the output will appear corrupted unless the file is greater than 8 bytes in size. The file untagged-file-with-ebcdic.txt is untagged and only contains EBCDIC characters.

Perl test program:

open(my $fh, '<', 'untagged-file-with-ebcdic.txt');
while (my $row = <$fh>) {
	chomp $row;
	print "$row\n";
}
close($fh);

Shell example:

$ chtag -r untagged-file-with-ebcdic.txt
$ od -Ax -xc untagged-file-with-ebcdic.txt
0000000000      F1F2    F3F4    F5F6    F715
               1   2   3   4   5   6   7  \n
0000000008
$ perl test.pl
�������

### Now try again with slightly bigger contents
$ od -Ax -xc untagged-file-with-ebcdic.txt
0000000000      F1F2    F3F4    F5F6    F7F8    1500
               1   2   3   4   5   6   7   8  \n
0000000009
$ perl test.pl 
12345678

Repeating the same sequence with the file tagged as IBM-1047:

$ chtag -r untagged-file-with-ebcdic.txt
$ od -Ax -xc untagged-file-with-ebcdic.txt
0000000000      F1F2    F3F4    F5F6    F715
               1   2   3   4   5   6   7  \n
0000000008
$ perl test.pl
1234567

### Now try again with slightly bigger contents
$ od -Ax -xc untagged-file-with-ebcdic.txt
0000000000      F1F2    F3F4    F5F6    F7F8    1500
               1   2   3   4   5   6   7   8  \n
0000000009
$ perl test.pl 
12345678
@IgorTodorovskiIBM
Copy link
Collaborator

Thanks, this is similar to the issue raised for nano. zopencommunity/nanoport#11

Most zopen tools leverage zoslib, which is the culprit here. You can try using the environment variable mentioned in the nano issue until we have a proper fix.

@chrishodgins
Copy link
Author

@IgorTodorovskiIBM thanks, I can confirm that setting export __UNTAGGED_READ_MODE=ASCII did resolve the issue for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants