File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2092,6 +2092,29 @@ def test_idempotent(self):
20922092 sp = c .to_splittable (s )
20932093 eq (s , c .from_splittable (sp ))
20942094
2095+ def test_body_encode (self ):
2096+ eq = self .assertEqual
2097+ # Try a charset with QP body encoding
2098+ c = Charset ('iso-8859-1' )
2099+ eq ('hello w=F6rld' , c .body_encode ('hello w\xf6 rld' ))
2100+ # Try a charset with Base64 body encoding
2101+ c = Charset ('utf-8' )
2102+ eq ('aGVsbG8gd29ybGQ=\n ' , c .body_encode ('hello world' ))
2103+ # Try a charset with None body encoding
2104+ c = Charset ('us-ascii' )
2105+ eq ('hello world' , c .body_encode ('hello world' ))
2106+ # Try the convert argument, where input codec <> output codec
2107+ c = Charset ('euc-jp' )
2108+ # With apologies to Tokio Kikuchi ;)
2109+ try :
2110+ eq ('\x1b $B5FCO;~IW\x1b (B' ,
2111+ c .body_encode ('\xb5 \xc6 \xc3 \xcf \xbb \xfe \xc9 \xd7 ' ))
2112+ eq ('\xb5 \xc6 \xc3 \xcf \xbb \xfe \xc9 \xd7 ' ,
2113+ c .body_encode ('\xb5 \xc6 \xc3 \xcf \xbb \xfe \xc9 \xd7 ' , False ))
2114+ except LookupError :
2115+ # We probably don't have the Japanese codecs installed
2116+ pass
2117+
20952118
20962119
20972120# Test multilingual MIME headers.
You can’t perform that action at this time.
0 commit comments