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

non_ascii_to_octal: Return the input string if it only contains printable ASCII characters #3199

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def non_ascii_to_octal(argstr):
>>> non_ascii_to_octal("ABC ±120° DEF α ♥")
'ABC \\261120\\260 DEF @~\\141@~ @%34%\\252@%%'
""" # noqa: RUF002
# Return the string if it only contains printable ASCII characters from 32 to 126.
if all(32 <= ord(c) <= 126 for c in argstr):
return argstr

# Dictionary mapping non-ASCII characters to octal codes
mapping = {}

Expand Down