diff --git a/base/mp_base64copy.sas b/base/mp_base64copy.sas index 9a949e5..9b52876 100644 --- a/base/mp_base64copy.sas +++ b/base/mp_base64copy.sas @@ -76,7 +76,7 @@ run; %if &outfound=0 %then %do; filename &outref temp lrecl=2097088; -%%end; +%end; %if &action=ENCODE %then %do; data _null_; @@ -84,12 +84,12 @@ run; retain line ""; infile &inref recfm=F lrecl= 1 end=eof; input @1 stream $char1.; - file &outref lrecl=76; + file &outref recfm=N; substr(line,(_N_-(CEIL(_N_/57)-1)*57),1) = byte(rank(stream)); if mod(_N_,57)=0 or EOF then do; if eof then b64=put(trim(line),$base64X76.); else b64=put(line, $base64X76.); - put b64; + put b64 + (-1) @; line=""; end; run; @@ -101,19 +101,13 @@ run; fileout = fopen("&outref",'O',3,'B'); char= '20'x; do while(fread(filein)=0); - raw="1234"; + length raw $4; do i=1 to 4; rc=fget(filein,char,1); substr(raw,i,1)=char; end; - val="123"; - val=input(raw,$base64X4.); - do i=1 to 3; - length byte $1; - byte=byte(rank(substr(val,i,1))); - rc = fput(fileout, byte); - end; - rc =fwrite(fileout); + rc = fput(fileout,input(raw,$base64X4.)); + rc = fwrite(fileout); end; rc = fclose(filein); rc = fclose(fileout); diff --git a/tests/base/mp_base64copy.test.sas b/tests/base/mp_base64copy.test.sas new file mode 100644 index 0000000..ec74803 --- /dev/null +++ b/tests/base/mp_base64copy.test.sas @@ -0,0 +1,67 @@ +/** + @file + @brief Testing mp_base64copy.sas macro + +