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

cat doesn't print files with "invalid unicode" #1240

Closed
TheGoddessInari opened this issue Jun 18, 2018 · 2 comments
Closed

cat doesn't print files with "invalid unicode" #1240

TheGoddessInari opened this issue Jun 18, 2018 · 2 comments
Labels

Comments

@TheGoddessInari
Copy link
Contributor

TheGoddessInari commented Jun 18, 2018

At least on Windows, it prints

1  cat: text was not valid unicode

when attempting to cat -n or cat -b a file with presumably invalid unicode. Without any other arguments, it prints a blank line. This is an important distinction because GNU cat, and redirecting input (like cat < file) both work. Only when passing the file via arguments does it fail in this way.

Notably, this fails with most executables.

@Arcterus
Copy link
Collaborator

This main part of this issue seems to be caused by rust-lang/rust#23344. I'm not really sure if there's an easy fix unfortunately. That said, I'm still not totally sure why the issue only shows up when opening a file directly. I'm guessing it has to do with stdin only reading in UTF-16 pairs or something so there is no need to worry about half pairs.

The other part should be split into a separate issue (I'd appreciate it if you would do so). We should not be separating the line number prefix write from the data write to avoid weird output like this.

@stale
Copy link

stale bot commented Mar 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 27, 2021
@stale stale bot closed this as completed Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants