Repository navigation
Preserve UTF-8 characters in process log output - #241
Open
bob sira (bobsira) wants to merge 1 commit into
Open
bob sira (bobsira) wants to merge 1 commit into
bob sira (bobsira) wants to merge 1 commit into
Conversation
Validate and preserve complete UTF-8 sequences in standard JSON and XML process logs instead of replacing every high-bit byte. Retain question-mark replacement for invalid bytes, add regression coverage, and document the supported encoding. Addresses #121.
There was a problem hiding this comment.
🟡 Changes recommended
Newly preserved U+FFFE and U+FFFF characters produce invalid XML and need XML-specific replacement.
1 open issue
What changed in this PR
This PR replaces the earlier byte-replacement workaround with UTF-8 preservation in standard process logs, addressing #121 while leaving custom formatting and pipe framing unchanged.
Changes:
- Preserve valid multibyte UTF-8 sequences while replacing invalid bytes and NUL.
- Add regression coverage for standard and custom formatting.
- Document the expected child-process encoding and lack of code-page conversion.
| File | Description |
|---|---|
LogMonitor/src/LogMonitor/ProcessMonitor.cpp |
Validate and preserve UTF-8 sequences in standard output. |
LogMonitor/LogMonitorTests/LogMonitorTests.cpp |
Cover UTF-8 preservation, malformed bytes, and existing formatting behavior. |
LogMonitor/docs/README.md |
Explain UTF-8 expectations for child-process output. |
Review effort: Balanced
| if (sequenceLength > 0 && | ||
| inputLine.size() - i >= static_cast<size_t>(sequenceLength) && | ||
| Utility::IsTextUTF8(inputLine.data() + i, sequenceLength)) { | ||
| sanitized.append(inputLine, i, sequenceLength); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #121 for UTF-8 child-process output.
The workaround introduced by #122 allowed processing to continue but replaced high-bit bytes with
?. The current standard formatter retained that behavior, corrupting valid multibyte characters in JSON and XML process logs.Utility::IsTextUTF8helper.?replacement for invalid bytes and NUL in the formatter, while preserving valid characters elsewhere in the line.This does not introduce legacy Windows code-page detection/conversion or repair text already corrupted by the child application.
Validation
?.<string>include diagnostic on both unchangedmainand this branch; no new lint diagnostics were introduced.Validation was scoped to process formatting and related utilities. The broader EventMonitor replay crash tracked in #238 is outside this change.