diff options
| author | Barry Warsaw | 2014-11-17 20:29:29 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2014-11-17 20:29:29 -0500 |
| commit | 0e9df01a559ee7c6bb0d4d307159ef29497e79c9 (patch) | |
| tree | eb15c3c742adeb64d6d14bdfe9567b0d8bf53dec /src/mailman/utilities/string.py | |
| parent | 639f3bcceded70867062c2ee4cf9a666b0f72516 (diff) | |
| download | mailman-0e9df01a559ee7c6bb0d4d307159ef29497e79c9.tar.gz mailman-0e9df01a559ee7c6bb0d4d307159ef29497e79c9.tar.zst mailman-0e9df01a559ee7c6bb0d4d307159ef29497e79c9.zip | |
Diffstat (limited to 'src/mailman/utilities/string.py')
| -rw-r--r-- | src/mailman/utilities/string.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/mailman/utilities/string.py b/src/mailman/utilities/string.py index 0ed7cdf95..d6f0da286 100644 --- a/src/mailman/utilities/string.py +++ b/src/mailman/utilities/string.py @@ -23,22 +23,16 @@ __metaclass__ = type __all__ = [ 'expand', 'oneline', - 'uncanonstr', - 'websafe', 'wrap', ] -import cgi import logging from email.errors import HeaderParseError from email.header import decode_header, make_header from string import Template, whitespace from textwrap import TextWrapper, dedent -from zope.component import getUtility - -from mailman.interfaces.languages import ILanguageManager EMPTYSTRING = '' @@ -92,45 +86,6 @@ def oneline(s, cset='us-ascii', in_unicode=False): -def websafe(s): - return cgi.escape(s, quote=True) - - - -# The opposite of canonstr() -- sorta. I.e. it attempts to encode s in the -# charset of the given language, which is the character set that the page will -# be rendered in, and failing that, replaces non-ASCII characters with their -# html references. It always returns a byte string. -def uncanonstr(s, lang=None): - if s is None: - s = u'' - if lang is None: - charset = 'us-ascii' - else: - charset = getUtility(ILanguageManager)[lang].charset - # See if the string contains characters only in the desired character - # set. If so, return it unchanged, except for coercing it to a byte - # string. - try: - if isinstance(s, unicode): - return s.encode(charset) - else: - unicode(s, charset) - return s - except UnicodeError: - # Nope, it contains funny characters, so html-ref it - a = [] - for c in s: - o = ord(c) - if o > 127: - a.append('&#%3d;' % o) - else: - a.append(c) - # Join characters together and coerce to byte string - return str(EMPTYSTRING.join(a)) - - - def wrap(text, column=70, honor_leading_ws=True): """Wrap and fill the text to the specified column. |
