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.
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
Support non-ASCII characters in ISO-8859-x charsets #3310
Support non-ASCII characters in ISO-8859-x charsets #3310
Changes from 12 commits
3bcf57f
4738815
9f0e0f1
21e91f1
01ef6b3
3c8b979
d946636
7aa07a0
6f3aae4
e2fa2c8
dca5079
32a6646
db590a3
7c9bed4
91818e1
9af4efb
4734520
df3679b
36b2a2f
78cc52b
2d01f6b
43ef0a2
586127d
e8ac6bb
6bd5008
5260749
556fee9
c414b4c
7607c7e
6728856
7a26bfc
1636453
d90dcc8
23a2806
3474bb2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on using
_check_encoding
to keep this function more private? I know we don't documentpygmt.helpers.utils
in the API docs, but want to avoid users from thinking that this function is somewhat public if there's no leading underscore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6728856.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be too much to have a typehint like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about that too. Actually the same types can be used in typing hints the
encoding
parameter of thenon_ascii_to_octal
function. So my initial plan is to define a generic typeand then use it like:
but mypy v1.10.0 complains
mypy v1.11.0 started to support PEP 695 but it was released just a few days ago (https://mypy-lang.blogspot.com/2024/07/mypy-111-released.html) and the PEP 695 support is still experimental.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7607c7e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the GMT-supported encodings, I'm thinking if we should return
ascii
(the nameascii
comes from https://docs.python.org/3/library/codecs.html#standard-encodings) if the input string only contains ASCII characters, e.g.,Since in most cases, the arguments and the text string contain ASCII characters only. When
ascii
encoding is detected, we no longer need to applynon_ascii_to_octal
to the strings, which may improve the performance for most cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 2d01f6b.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function returns
ISOLatin1+
/ISO-8859-1
/.../ISO-8859-16
, but Python's standard encodings arelatin_1
/iso8859_1
/...iso8859_16
(https://docs.python.org/3/library/codecs.html#standard-encodings). They're inconsistent, but using names likeISOLatin1+
can greatly simplify the codes.