Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data work.encode;
- infile datalines;
- input text_enc $60.;
- datalines;
- ABCABlABjABhAB1ABzABlAAgABVABUABGAA4AAgABpABzAAgABoABhAByABk
- ABTABpABtABwABsABlAByAAgABsABpABrABlAAgAB0ABoABpABz
- ABJABvAAgABJABvAAgABCAByABvABtABpABvABz
- ;
- run;
- /* Set up the functions */
- proc fcmp outlib=work.funcs.text;
- function deencode(enc $) $;
- len_enc = length(trim(enc));
- collate = ' ';
- if int(len_enc/3) = (len_enc/3) then do;
- array conversion{128} _temporary_ (.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,62,.,.,.,63,52,53,54,55,56,57,58,59,60,61,.,.,.,.,.,.,., 0, 1, 2, 3, 4,5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,.,.,.,.,.,.,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,.,.,.,.,.);
- array final{60} $ /NOSYMBOLS;
- do i=1 to int(len_enc/3);
- currentpart = substr(enc,(i*3)-2,3);
- unichar = "\u"!!put(blshift(conversion{1+rank(char(currentpart,1))},12)+blshift(conversion{1+rank(char(currentpart,2))},6)+conversion{1+rank(char(currentpart,3))},hex4.);
- final{i} = unicode(unichar);
- collate = trim(collate)!!trim(final{i});
- end;
- *outtext = cat(of final{*});
- return (trim(collate));
- end;
- else return ('');
- endsub;
- /* Run the code */
- options cmplib=work.funcs;
- data work.function_test;
- set work.encode;
- length finaltext $400.;
- finaltext = deencode(text_enc);
- run;
- proc print data = work.function_test;
- run;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement