Fix JSON encoding to preserve Unicode characters like µA#2707
Merged
Conversation
The change in PR #2535 to support binary commands incorrectly encoded valid UTF-8 Unicode characters (e.g., µA for micro-Ampères) as raw byte arrays. This was caused by an overly aggressive early return that treated all ASCII-8BIT strings with bytes > 127 as binary data. The fix removes this early return and relies on UTF-8 validity checking to distinguish between true binary data (invalid UTF-8) and Unicode text (valid UTF-8 stored in ASCII-8BIT strings). Added regression tests for both Ruby and Python to prevent future issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2707 +/- ##
==========================================
- Coverage 79.23% 79.23% -0.01%
==========================================
Files 664 664
Lines 52823 52821 -2
Branches 734 734
==========================================
- Hits 41854 41851 -3
- Misses 10889 10890 +1
Partials 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Test plan
openc3/spec/io/json_rpc_spec.rb)openc3/python/test/io/test_json_rpc.py)\xDE\xAD\xBE\xEF) still encodes as raw object0.5 µA,25 °C) is preserved as readable string🤖 Generated with Claude Code