Fix UnicodeDecodeError on Windows by standardizing to UTF-8 encoding#311
Open
dvmukul wants to merge 1 commit intoDavidyz:mainfrom
Open
Fix UnicodeDecodeError on Windows by standardizing to UTF-8 encoding#311dvmukul wants to merge 1 commit intoDavidyz:mainfrom
dvmukul wants to merge 1 commit intoDavidyz:mainfrom
Conversation
Added explicit encoding='utf-8' to multiple open() calls to ensure consistent behavior across different platforms, specifically fixing UnicodeDecodeError on Windows when reading repository files or configuration specs. Fixes Issue Davidyz#307
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.
This PR standardises Unicode encodings to UTF-8 across the codebase by adding explicit
encoding='utf-8'toopen()calls.Rationale
On Windows, the default locale encoding (e.g., CP1252 or CP949) often differs from UTF-8. When
vectorcodeattempts to read code files or configuration files containing non-ASCII characters without an explicit encoding, it throws aUnicodeDecodeError.This has been reported in Issue #307, specifically for the
querycommand.Changes
src/vectorcode/subcommands/query/__init__.pyto use UTF-8 when reading document source during query result building.src/vectorcode/subcommands/vectorise.pyto use UTF-8 for include/exclude specifications.src/vectorcode/subcommands/init.pyfor git hook and configuration file operations.src/vectorcode/cli_utils.pyfor general configuration loading.src/vectorcode/mcp_main.pyfor MCP tool result processing.These changes ensure that
vectorcoderemains robust and cross-platform compatible when handling modern UTF-8 codebase files.