diff options
| author | tkikuchi | 2007-03-02 12:36:15 +0000 |
|---|---|---|
| committer | tkikuchi | 2007-03-02 12:36:15 +0000 |
| commit | a39a27fce459fb6fc4d0c1ee17ab571d51bf16bf (patch) | |
| tree | 97824a5764d9924e283ba0c2c94e39bc6cd0a3b1 /Mailman/Utils.py | |
| parent | 173997db20a1fad4ec6a78e0c7a88e147869cd7d (diff) | |
| download | mailman-a39a27fce459fb6fc4d0c1ee17ab571d51bf16bf.tar.gz mailman-a39a27fce459fb6fc4d0c1ee17ab571d51bf16bf.tar.zst mailman-a39a27fce459fb6fc4d0c1ee17ab571d51bf16bf.zip | |
Diffstat (limited to 'Mailman/Utils.py')
| -rw-r--r-- | Mailman/Utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 5844d708c..958a3e959 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -826,13 +826,16 @@ def uquote(s): return str(EMPTYSTRING.join(a)) -def oneline(s, cset): +def oneline(s, cset='us-ascii', in_unicode=False): # Decode header string in one line and convert into specified charset try: h = email.Header.make_header(email.Header.decode_header(s)) ustr = h.__unicode__() line = UEMPTYSTRING.join(ustr.splitlines()) - return line.encode(cset, 'replace') + if in_unicode: + return line + else: + return line.encode(cset, 'replace') except (LookupError, UnicodeError, ValueError, HeaderParseError): # possibly charset problem. return with undecoded string in one line. return EMPTYSTRING.join(s.splitlines()) |
