Ensuring 7 bit encoding

View: New views
3 Messages — Rating Filter:   Alert me  

Ensuring 7 bit encoding

by Nicholas Cole :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I hope that this question has a trivial answer, but that people won't
mind me asking it here. I've been googling the subject, but can't
quite get a handle on it.

What do I need to do to ensure that emails are generated only in 7,
not 8-bit encodings?  I assume that I need to use
email.charset.add_charset , but can't quite work out what incantation
to give it.  Does anyone have any pointers?

Best wishes,

Nicholas
_______________________________________________
Email-SIG mailing list
Email-SIG@...
Your options: http://mail.python.org/mailman/options/email-sig/lists%40nabble.com

Re: Ensuring 7 bit encoding

by Mark Sapiro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nicholas Cole wrote:
>
>What do I need to do to ensure that emails are generated only in 7,
>not 8-bit encodings?  I assume that I need to use
>email.charset.add_charset , but can't quite work out what incantation
>to give it.  Does anyone have any pointers?


I'm not sure what it is you're asking. Does this answer your question?

>>> import email.message
>>> m = email.message.Message()
>>> m.set_payload("""A few lines
... of 7-bit text
...
... No high bit characters.
... """, 'us-ascii')
>>> print m.as_string()
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

A few lines
of 7-bit text

No high bit characters.

>>>


--
Mark Sapiro <mark@...>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

_______________________________________________
Email-SIG mailing list
Email-SIG@...
Your options: http://mail.python.org/mailman/options/email-sig/lists%40nabble.com

Parent Message unknown Re: Ensuring 7 bit encoding

by Stephen J. Turnbull :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

R. David Murray writes:

 > >>> import email.message
 > >>> m = email.message.Message()
 > >>> m.set_payload("""A few lines
 > ... of 8-bit text
 > ...
 > ... One high bit character: ².
 > ... """, 'us-ascii')
 > >>> print m.as_string()
 > MIME-Version: 1.0
 > Content-Type: text/plain; charset="us-ascii"
 > Content-Transfer-Encoding: 8bit
 >
 > A few lines
 > of 8-bit text
 >
 > One high bit character: ².
 >
 > >>>
 >
 > Since 8bit isn't technically us-ascii, I wonder if this is a bug.

This is a bug.

_______________________________________________
Email-SIG mailing list
Email-SIG@...
Your options: http://mail.python.org/mailman/options/email-sig/lists%40nabble.com