Link to home
Start Free TrialLog in
Avatar of valvet
valvet

asked on

Yet another Pascal to C#

ciuly: You might remember our byte array from the other post, 'a'. This is what's being used here.

function deb(b:string):string;
var base: string;
    i, r, j: integer;
    b1, b2, b3, b4: byte;
    i1, i2, i3: byte;
begin
       
 i := 1;
 while i+4<Length(b) do begin
 
   b1 := a[ord(b[i])-20];
   b2 := a[ord(b[i+1])-20];
   b3 := a[ord(b[i+2])-20];
   b4 := a[ord(b[i+3])-20];

    i1 := (b1 shl 2)or(b2 shr 4);
    i2 := ((b2 and $f) shl 4)or(b3 shr 2);
    i3 := ((b3 and 3) shl 6)or(b4);

   //if i1*i2*i3<>0 then                  
   result := result + {'>'+}chr(i1)+chr(i2)+chr(i3);
   //result := result +
   //'|'+ int2str(i1)+','+ int2str(i2)+','+ int2str(i3)+
   //'('+int2str(b1)+','+ int2str(b2)+','+ int2str(b3)+','+int2str(b4)+')';

   inc(i,4);
 end;
end;
ASKER CERTIFIED SOLUTION
Avatar of 2266180
2266180
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of valvet
valvet

ASKER

Excellent job.

Workes like a charm.