From e1afbc02c41fd9443c86faa2df527cc58fe35cb2 Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Sat, 25 Jun 2022 21:32:21 +0000 Subject: [PATCH] fix: enabling binary copy of files with encoding that does not match session encoding --- all.sas | 17 ++++++----------- base/mp_binarycopy.sas | 17 ++++++----------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/all.sas b/all.sas index 50cc9b2..7a5d2cf 100644 --- a/all.sas +++ b/all.sas @@ -3529,18 +3529,13 @@ run; /* copy the file byte-for-byte */ data _null_; - length filein 8 fileid 8; - filein = fopen("&inref",'I',1,'B'); - fileid = fopen("&outref",&outmode,1,'B'); - rec = '20'x; - do while(fread(filein)=0); - rc = fget(filein,rec,1); - rc = fput(fileid, rec); - rc =fwrite(fileid); - end; - rc = fclose(filein); - rc = fclose(fileid); + infile &inref; + file &outref; + input sourcechar $char1. @@; + format sourcechar hex2.; + put sourcechar char1. @@; run; + %if &inref = ____in %then %do; filename &inref clear; %end; diff --git a/base/mp_binarycopy.sas b/base/mp_binarycopy.sas index abc7e91..57377d8 100755 --- a/base/mp_binarycopy.sas +++ b/base/mp_binarycopy.sas @@ -63,18 +63,13 @@ /* copy the file byte-for-byte */ data _null_; - length filein 8 fileid 8; - filein = fopen("&inref",'I',1,'B'); - fileid = fopen("&outref",&outmode,1,'B'); - rec = '20'x; - do while(fread(filein)=0); - rc = fget(filein,rec,1); - rc = fput(fileid, rec); - rc =fwrite(fileid); - end; - rc = fclose(filein); - rc = fclose(fileid); + infile &inref; + file &outref; + input sourcechar $char1. @@; + format sourcechar hex2.; + put sourcechar char1. @@; run; + %if &inref = ____in %then %do; filename &inref clear; %end;