Skip to content

Commit 839c9e7

Browse files
committed
updates
1 parent 7f944ae commit 839c9e7

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

pygmt/encodings.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
>>> from pygmt.encodings import charset
77
>>>
8-
>>> mappings = charset["symbol"]
8+
>>> mappings = charset["Symbol"]
99
>>>
1010
>>> undefined = "\ufffd"
1111
>>> markdown = "| octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |\n"
@@ -35,7 +35,7 @@
3535
# same issue.
3636
# 3. Character \140 does not appear in Unicode.
3737
# 4. \ufffd means the character is undefined.
38-
charset["symbol"] = dict(
38+
charset["Symbol"] = dict(
3939
zip(
4040
[*range(0o040, 0o200), *range(0o240, 0o400)],
4141
"\u0020\u0021\u2200\u0023\u2203\u0025\u0026\u220b"
@@ -71,7 +71,7 @@
7171
# References:
7272
# 1. https://en.wikipedia.org/wiki/Zapf_Dingbats
7373
# 2. https://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/zdingbat.txt
74-
charset["zdingbat"] = dict(
74+
charset["ZapfDingbats"] = dict(
7575
zip(
7676
[*range(0o040, 0o220), *range(0o240, 0o400)],
7777
"\u0020\u2701\u2702\u2703\u2704\u260e\u2706\u2707"
@@ -108,12 +108,21 @@
108108
#
109109
# References:
110110
# 1. https://en.wikipedia.org/wiki/ISO/IEC_8859-1
111+
# 2. https://en.wikipedia.org/wiki/PostScript_Latin_1_Encoding
111112
# 2. https://docs.generic-mapping-tools.org/dev/reference/octal-codes.html
112113
# 3. https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf
113114
# 4. https://github.com/adobe-type-tools/agl-aglfn/blob/master/aglfn.txt
114115
charset["ISOLatin1+"] = {
115116
i: chr(i) for i in [*range(0o040, 0o177), *range(0o241, 0o400)]
116117
}
118+
# \047 and \140 are apostrophe (') and backtick (`) in ISO-8859-1, but are right/left
119+
# single quotation marks (’ and ‘) in ISOLatin1+ Encoding. # noqa: RUF003
120+
charset["ISOLatin1+"].update(
121+
{
122+
0o140: "\u2018", # LEFT SINGLE QUOTATION MARK ‘ # noqa: RUF003
123+
0o047: "\u2019", # RIGHT SINGLE QUOTATION MARK ’ # noqa: RUF003
124+
}
125+
)
117126
charset["ISOLatin1+"].update(
118127
dict(
119128
zip(

pygmt/helpers/utils.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,21 @@ def data_kind(data=None, x=None, y=None, z=None, required_z=False, required_data
206206
return kind
207207

208208

209-
def non_ascii_to_octal(argstr):
209+
def non_ascii_to_octal(argstr: str) -> str:
210210
r"""
211211
Translate non-ASCII characters to their corresponding octal codes.
212212
213-
Currently, only characters in the ISOLatin1+ charset and
214-
Symbol/ZapfDingbats fonts are supported.
213+
Currently, only characters in the ISOLatin1+ charset and Symbol/ZapfDingbats fonts
214+
are supported.
215215
216216
Parameters
217217
----------
218-
argstr : str
218+
argstr
219219
The string to be translated.
220220
221221
Returns
222222
-------
223-
translated_argstr : str
223+
translated_argstr
224224
The translated string.
225225
226226
Examples
@@ -241,14 +241,11 @@ def non_ascii_to_octal(argstr):
241241
# Dictionary mapping non-ASCII characters to octal codes
242242
mapping = {}
243243
# Adobe Symbol charset.
244-
mapping.update({c: f"@~\\{i:03o}@~" for i, c in charset["symbol"].items()})
245-
# Adobe ZDingbat charset.
246-
mapping.update({c: f"@%34%\\{i:o}@%%" for i, c in charset["zdingbat"].items()})
247-
248-
# Adobe ISOLatin1+ charset (i.e., ISO-8859-1 with extensions).
244+
mapping.update({c: f"@~\\{i:03o}@~" for i, c in charset["Symbol"].items()})
245+
# Adobe ZapfDingbats charset.
246+
mapping.update({c: f"@%34%\\{i:o}@%%" for i, c in charset["ZapfDingbats"].items()})
247+
# Adobe ISOLatin1+ charset.
249248
mapping.update({c: f"\\{i:o}" for i, c in charset["ISOLatin1+"].items()})
250-
mapping["\u2018"] = "\\140" # LEFT SINGLE QUOTATION MARK ‘ # noqa: RUF003
251-
mapping["\u2019"] = "\\047" # RIGHT SINGLE QUOTATION MARK ’ # noqa: RUF003
252249

253250
# Remove any printable characters
254251
mapping = {k: v for k, v in mapping.items() if k not in string.printable}

0 commit comments

Comments
 (0)