Permalink
Browse files

[GH #813 + #814] Fix MIME/Base64.pir for encoded strings

Use bytebuffer representations of the encoded string, not the encoded ord value.
Now the implementation is correct, but some encoded tests not.
  • Loading branch information...
1 parent d747438 commit 3a48e6b462d8fff501cb16a2f92a857baee0df53 @rurban rurban committed Sep 24, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 runtime/parrot/library/MIME/Base64.pir
@@ -94,13 +94,17 @@ then a warning is generated if perl is running under -w.
.local int len, len_mod_3
len = length plain
- len_mod_3 = len % 3
+ .local pmc bb
+ bb = new ['ByteBuffer'], len
+ bb = plain
+ len = elements bb
+ len_mod_3 = len % 3
# Fill up with with null bytes
if len_mod_3 == 0 goto END_1
- plain = concat plain, ascii:"\0"
+ push bb, 0
if len_mod_3 == 2 goto END_1
- plain = concat plain, ascii:"\0"
+ push bb, 0
END_1:
base64 = ''
@@ -118,11 +122,11 @@ then a warning is generated if perl is running under -w.
# read 3*8 bits
# TODO GH #813 and #814 unicode chars
- eight_0 = ord plain, i
+ eight_0 = bb[i]
inc i
- eight_1 = ord plain, i
+ eight_1 = bb[i]
inc i
- eight_2 = ord plain, i
+ eight_2 = bb[i]
inc i
# d[i]>>2;

0 comments on commit 3a48e6b

Please sign in to comment.