Skip to content

Non-ascii 8-bit string handling #494

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

Merged
merged 2 commits into from
Sep 30, 2011
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion examples/pylab_examples/font_table_ttf.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
for ccode, glyphind in codes:
if ccode>=256: continue
r,c = divmod(ccode,16)
s = chr(ccode)
s = unichr(ccode)
chars[r][c] = s


Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,11 @@ def __call__(self, key):
def is_math_text(s):
# Did we find an even number of non-escaped dollar signs?
# If so, treat is as math text.
s = unicode(s)
try:
s = unicode(s)
except UnicodeDecodeError:
raise ValueError(
"matplotlib display text must have all code points < 128 or use Unicode strings")

dollar_count = s.count(r'$') - s.count(r'\$')
even_dollars = (dollar_count > 0 and dollar_count % 2 == 0)
Expand Down