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

Allow text file preview for all UTF-8 encoded files #977

Open
eulores opened this issue Jan 26, 2025 · 0 comments
Open

Allow text file preview for all UTF-8 encoded files #977

eulores opened this issue Jan 26, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@eulores
Copy link

eulores commented Jan 26, 2025

A number of PDF files converted into text (mutool convert...) still have few innocuous control characters (typically 0x0c replacing a page break). But these bug Broot into displaying them as hex dumps.

Please consider this patch below for Broot to be more lenient and accept all UTF-8 encoded files, simply by replacing control characters with space (or an empty string).

Binary files are unaffected by this patch, as they get rejected earlier by not being UTF-8 compliant.

diff --git a/src/syntactic/syntactic_view.rs b/src/syntactic/syntactic_view.rs
             self.total_lines_count += 1;
             let start = offset;
             offset += line.len();
+            line = line.replace(|ch: char| ch.is_control() && !"\t\n\r".contains(ch), " ");
-            for c in line.chars() {
-                if !is_char_printable(c) {
-                    debug!("unprintable char: {:?}", c);
-                    return Err(ProgramError::UnprintableFile);
-                }
-            }
@eulores eulores added the bug Something isn't working label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant