Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use utf-8 encodings for all text files #918

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Conversation

cpacker
Copy link
Collaborator

@cpacker cpacker commented Jan 24, 2024

The necessity to specify encoding="utf-8" in your open function calls largely depends on the environment in which your code is running. In Python, when opening a file for reading or writing, the default encoding used is platform dependent. For instance:

On Linux and macOS, the default encoding is typically UTF-8.
On Windows, it's usually not UTF-8 (more commonly CP1252 or a similar Windows-specific encoding).
If your code is expected to run in different environments, or if the files you are working with are explicitly encoded in UTF-8, it's a good practice to specify encoding="utf-8" in your open calls. This ensures consistency across different platforms and avoids potential issues with character encoding, especially when dealing with non-ASCII characters.

In summary, for both reading and writing configuration files, it's a good practice to explicitly set encoding="utf-8". This approach promotes consistency, portability, and reduces the risk of encountering encoding-related errors.

@cpacker cpacker changed the title fix: set encoding during settings file read fix: use utf-8 encodings for all text files Jan 29, 2024
@cpacker cpacker requested a review from sarahwooders January 29, 2024 03:19
Copy link
Collaborator

@sarahwooders sarahwooders left a comment

Choose a reason for hiding this comment

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

lgtm!

@cpacker cpacker merged commit 6edffe0 into main Jan 30, 2024
6 checks passed
@cpacker cpacker deleted the fix-utf8-localllm-json branch January 30, 2024 20:00
norton120 pushed a commit to norton120/MemGPT that referenced this pull request Feb 15, 2024
mattzh72 pushed a commit that referenced this pull request Oct 9, 2024
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