Skip to content

Commit bc673bc

Browse files
authored
non_ascii_to_octal: Return the input string if it only contains printable ASCII characters (#3199)
1 parent 8592b54 commit bc673bc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pygmt/helpers/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ def non_ascii_to_octal(argstr):
233233
>>> non_ascii_to_octal("ABC ±120° DEF α ♥")
234234
'ABC \\261120\\260 DEF @~\\141@~ @%34%\\252@%%'
235235
""" # noqa: RUF002
236+
# Return the string if it only contains printable ASCII characters from 32 to 126.
237+
if all(32 <= ord(c) <= 126 for c in argstr):
238+
return argstr
239+
236240
# Dictionary mapping non-ASCII characters to octal codes
237241
mapping = {}
238242

0 commit comments

Comments
 (0)