fix: force UTF-8 encoding for non-UTF8 locales#130
Merged
Conversation
The CLI now explicitly sets UTF-8 encoding for external and internal strings to prevent encoding errors when run in environments with C/POSIX locales (e.g., Homebrew test sandboxes). Bump version to 2.3.1
16149bf to
1eaca6e
Compare
Contributor
Greptile SummaryFixed encoding errors in non-UTF8 locales (like Homebrew's C/POSIX test sandbox) by forcing UTF-8 encoding in the CLI executable and bumped version to 2.3.1.
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI as exe/classifier
participant Ruby as Ruby Runtime
participant ClassifierCLI as Classifier::CLI
User->>CLI: Execute classifier command
CLI->>Ruby: Set Encoding.default_external = UTF-8
CLI->>Ruby: Set Encoding.default_internal = UTF-8
Note over CLI,Ruby: Forces UTF-8 encoding for C/POSIX locales
CLI->>ClassifierCLI: require 'classifier/cli'
CLI->>ClassifierCLI: new(ARGV).run
ClassifierCLI-->>CLI: result hash
CLI->>CLI: warn result[:error] unless empty?
CLI->>CLI: puts result[:output] unless empty?
CLI->>User: exit result[:exit_code]
|
| #!/usr/bin/env ruby | ||
| # frozen_string_literal: true | ||
|
|
||
| # Force UTF-8 encoding for proper handling of model data and user input |
Contributor
There was a problem hiding this comment.
style: comment restates what the code already shows
Suggested change
| # Force UTF-8 encoding for proper handling of model data and user input |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: exe/classifier
Line: 4:4
Comment:
**style:** comment restates what the code already shows
```suggestion
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
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
Problem
When running
classifierin environments with non-UTF8 locales (like Homebrew's test sandbox which usesLC_ALL=C), the CLI fails with:Solution
Explicitly set
Encoding.default_externalandEncoding.default_internalto UTF-8 at CLI startup.Test