Skip to content

Comments

Fix utf8 decode error#818

Merged
hulto merged 5 commits intomainfrom
fix-utf8-decode-error
Jan 26, 2025
Merged

Fix utf8 decode error#818
hulto merged 5 commits intomainfrom
fix-utf8-decode-error

Conversation

@hulto
Copy link
Collaborator

@hulto hulto commented Jan 6, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

Some windows commands specificall tree C:\\Users\\testuser\\ return characters outside the utf8 standard.
Instead of switching to utf16 or trying different decode methods this solution replaces unknown characters with a place holder.

This avoids the function crashing and doesn't increase code complexity.

Which issue(s) this PR fixes:

Fixes #

@hulto hulto force-pushed the fix-utf8-decode-error branch from 2d4b89a to b365adc Compare January 15, 2025 02:04
@hulto hulto added this to the v0.2.0 milestone Jan 26, 2025
result_string =
String::from(String::from_utf8(response_buffer.to_vec())?.trim_matches(char::from(0)));
result_string = String::from(
String::from_utf8_lossy(&response_buffer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do debug logging for when this happens? Might be a pain if this fails silently and causes other errors downstream

@hulto hulto merged commit 4fa556b into main Jan 26, 2025
6 checks passed
@hulto hulto deleted the fix-utf8-decode-error branch January 26, 2025 17:27
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

Successfully merging this pull request may close these issues.

2 participants