|
Posted by sonet on June 5, 2007, 4:21 am
Please log in for more thread options
The MIME::Base64 will convert \n to \r\n.
$a="1234\n4567\n";
$a=encode_base64($a,0);
print decode_base64($a);
The result is 1234\r\n4567\r\n.
|
|
Posted by Sisyphus on June 5, 2007, 5:41 am
Please log in for more thread options
> The MIME::Base64 will convert \n to \r\n.
>
> $a="1234\n4567\n";
> $a=encode_base64($a,0);
> print decode_base64($a);
>
> The result is 1234\r\n4567\r\n.
>
Can't reproduce that on any of my Win32 builds of perl, or on linux:
A copy'n'paste from Windows:
-----------------------------
C:\pscrpt>type try.pl
use warnings;
use MIME::Base64;
$a="1234\n4567\n";
$a=encode_base64($a,0);
$z = decode_base64($a);
print "\r => ", ord("\r"), "\n";
print "\n => ", ord("\n"), "\n";
for(0..length($z) - 1) {
print ord(substr($z, $_, 1)), " ";
}
C:\pscrpt>perl try.pl
\r => 13
\n => 10
49 50 51 52 10 52 53 54 55 10
C:\pscrpt>
-----------------------------
And the same script produces the same output on linux for me.
Cheers,
Rob
|
|
Posted by Gunnar Hjalmarsson on June 5, 2007, 6:57 am
Please log in for more thread options
sonet wrote:
> The MIME::Base64 will convert \n to \r\n.
>
> $a="1234\n4567\n";
> $a=encode_base64($a,0);
> print decode_base64($a);
>
> The result is 1234\r\n4567\r\n.
How did you come to that conclusion?
Could it possibly be that your observation has something to do with
http://perldoc.perl.org/perlport.html#Newlines ?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|
|
Posted by Marcus Beranek on June 16, 2007, 9:04 am
Please log in for more thread options
sonet wrote:
> The MIME::Base64 will convert \n to \r\n.
>
> $a="1234\n4567\n";
> $a=encode_base64($a,0);
> print decode_base64($a);
>
> The result is 1234\r\n4567\r\n.
Maybe this is caused by the following: the microsoft implementation of stdio
converts the "\n" to a "\r\n" automaticly on input/output. so you can have
a "\n" in memory throughout your whole perl-script, but upon printing or
writing to file it gets converted ...
But i'm not quite sure about this, maybe there are also different flavours
of stdio, which behave differently, i don't know.
HTH,
Marcus
--
-mb-
|
|
Posted by liol on June 18, 2007, 7:17 am
Please log in for more thread options
> The MIME::Base64 will convert \n to \r\n.
>
> $a="1234\n4567\n";
> $a=encode_base64($a,0);
> print decode_base64($a);
>
> The result is 1234\r\n4567\r\n.
Look for http://www.ietf.org/rfc/rfc2045.txt [Page 25]
Care must be taken to use the proper octets for line breaks if
base64
encoding is applied directly to text material that has not been
converted to canonical form. In particular, text line breaks must
be
converted into CRLF sequences prior to base64 encoding. The
important thing to note is that this may be done directly by the
encoder rather than in a prior canonicalization step in some
implementations.
This RFC requirement.
Regards, LIOL
|
| Similar Threads | Posted | | Convert from base64 to TIFF or BMP or JPG | September 24, 2004, 12:15 am |
| Output binary data in base64 in YAML | January 14, 2005, 7:20 pm |
| MIME::Types 1.16 and OpenDocument | November 9, 2005, 7:48 am |
| How to log the output of Mime::Lite ? | June 26, 2006, 6:52 pm |
| Perl Module for S/MIME | October 19, 2006, 1:58 am |
| Perl Module for S/MIME | October 19, 2006, 1:59 am |
| Perl Mime::Lite question. Help please? | August 24, 2004, 8:45 am |
| MIME::Lite need sendmail Queue ID | November 16, 2006, 9:34 am |
| MIME::EncWords charset param | February 20, 2007, 7:03 pm |
| Composing MIME-compliant mail messages | July 8, 2004, 4:08 pm |
|