By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,520 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,520 IT Pros & Developers. It's quick & easy.

character set gobbledy-gook ascii translation ...

P: n/a

I'm parsing a file with the mailbox and email modules and
come across subject headers like:
=?us-ascii?Q?Re=3A=20=5Bosg=2Duser=5D=20Culling=20probl em?=
=?gb2312?B?cXVlc3Rpb24gYWJvdXQgbG9hZGluZyBmbHQgbGF yZ2UgdGVycmFpbiA=?=

I've looked at the Charset class but can't figure out how to use it to
convert the above strings to a human readable form. Generally, I
imagine that
there is no guarantee that an encoded string can be rendered meaningfully
in ASCII - but these are posts to an English language mai list so it should
be possible for this restricted case.

I can guess the translation in the first example above but I'm
hoping there is a Python module that'll do it for me.

Any help is much appreciated.

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
>>> email.Header.decode_header("=?us-ascii?Q?Re=3A=20=5Bosg=2Duser=5D=20Culling=20probl em?=")
[('Re: [osg-user] Culling problem', 'us-ascii')]
email.Header.decode_header("=?gb2312?B?cXVlc3Rpb24 gYWJvdXQgbG9hZGluZyBmbHQgbGFyZ2UgdGVycmFpbiA=?=") [('question about loading flt large terrain ', 'gb2312')] help(email.Header.decode_header)

Help on function decode_header:

Decode a message header value without converting charset.

Returns a list of (decoded_string, charset) pairs containing each of
the decoded parts of the header. Charset is None for non-encoded
parts of the header, otherwise a lower-case string containing the
name of the character set specified in the encoded string.

An email.Errors.HeaderParseError may be raised when certain decoding
error occurs (e.g. a base64 decoding exception).


Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBzCp3Jd01MZaTXX0RAgK+AJ40xiymdMBLvsexCNC4zm zEwqr16ACfXkZn

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.