Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ronaldxs/perl6-Enc-MIME-Base64
base: 93fc130ad1
...
head fork: ronaldxs/perl6-Enc-MIME-Base64
compare: 43837d25b9
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 13 additions and 3 deletions.
  1. +11 −2 lib/PP/Enc/MIME/Base64.pm6
  2. +2 −1  t/binary.t
View
13 lib/PP/Enc/MIME/Base64.pm6
@@ -10,6 +10,7 @@ module PP::Enc::MIME::Base64:auth<ronaldxs>:ver<0.01> {
# that implementation here but note it for anyone considering
# a parrot or external library implementation
+ ######################################################################
our Str sub encode_base64(Buf $b, Str $eol = "\n") is export {
my Str $rc = '';
my Str $padding_suffix = '';
@@ -45,8 +46,10 @@ module PP::Enc::MIME::Base64:auth<ronaldxs>:ver<0.01> {
return $rc ~ $padding_suffix;
}
+ ######################################################################
# Greatly wondering whether building everything in a list of Int
# and then newing the Buf is the most efficient way
+ ######################################################################
our Buf sub decode_base64(Str $s) is export {
my Int @rc;
my Str $end_pad = ($s ~~ /\= ** 1..2\s*/).Str;
@@ -73,11 +76,17 @@ module PP::Enc::MIME::Base64:auth<ronaldxs>:ver<0.01> {
return Buf.new(@rc);
}
- our Str sub encode_base64_str(Str $s, Str $e = 'utf-8', :$eol = "\n") is export {
+ ######################################################################
+ our Str sub encode_base64_str(Str $s, Str $e = 'utf-8', :$eol = "\n")
+ is export
+ {
encode_base64($s.encode($e), $eol);
}
- our Str sub decode_base64_str(Str $s, Str $d = 'utf-8') is export {
+ ######################################################################
+ our Str sub decode_base64_str(Str $s, Str $d = 'utf-8')
+ is export
+ {
decode_base64($s).decode($d);
}
View
3  t/binary.t
@@ -18,7 +18,8 @@ ok decode_base64('/w==') eq Buf.new(255), 'decode Test on byte value 255';
my Buf $camelia_ico = slurp(
$?FILE.path.directory ~ '/data/camelia-favicon.ico', :bin
);
-my Str $camelia_b64 = slurp(
+# .b64 file generated from .ico file with gnu base64 program
+my Str $camelia_b64 = slurp(
$?FILE.path.directory ~ '/data/camelia-favicon.b64'
);
is encode_base64($camelia_ico), $camelia_b64.chomp, 'binary img encode test';

No commit comments for this range

Something went wrong with that request. Please try again.