On Wed, Feb 28, 2007 at 09:18:06PM +0900, Urabe Shyouhei
wrote:
> Brian Candler wrote:
> > That is, non-printable characters (here a
UTF8-encoded BOM) are causing MIME
> > unpack to return garbage.
> >
> Fixed. Thanks reporting.
base64 decoding has same problem, doesn't it?
> bom = "xEFxBBxBF"
=> "357273277"
> b64 = ["hello"].pack('m*')
=> "aGVsbG8=n"
> (bom + b64).unpack('m*')
=> ["$ 00 32 31[ee"]
Also:
Any characters outside of the base64 alphabet are to be
ignored in
base64-encoded data.
- RFC2045, section 6.8
Instread, Ruby truncates input:
>
["a"*40+"b"*20].pack('m*').sub("n&
quot;, " n").unpack('m*')
=>
["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"]
It is common for extra whitespace, at ends of line for
example, to be
present in base64.
Sam
|