Kaydet (Commit) 2e74541d authored tarafından Greg Ward's avatar Greg Ward

Fix SF bug #622831 (I think): add unicode_whitespace_trans class

attribute, and modify _munge_whitespace() to recognize Unicode strings
and use unicode_whitespace_trans to munge them.  Still need to add a
test to make sure I've really fixed the bug.
üst ef8b9c66
......@@ -51,6 +51,10 @@ class TextWrapper:
whitespace_trans = string.maketrans(string.whitespace,
' ' * len(string.whitespace))
unicode_whitespace_trans = {}
for c in string.whitespace:
unicode_whitespace_trans[ord(unicode(c))] = ord(u' ')
# This funky little regex is just the trick for splitting
# text up into word-wrappable chunks. E.g.
# "Hello there -- you goof-ball, use the -b option!"
......@@ -99,7 +103,10 @@ class TextWrapper:
if self.expand_tabs:
text = text.expandtabs()
if self.replace_whitespace:
text = text.translate(self.whitespace_trans)
if isinstance(text, str):
text = text.translate(self.whitespace_trans)
elif isinstance(text, unicode):
text = text.translate(self.unicode_whitespace_trans)
return text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment