?
Solved

Yet another Pascal to C#

Posted on 2006-10-19
2
Medium Priority
?
1,114 Views
Last Modified: 2011-09-20
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;
0
Comment
Question by:valvet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 2000 total points
ID: 17764205
this should be it:

        public string deb(byte[] a, string b)
        {
            string result = "";
            byte b1,b2,b3,b4;
            int i = 1, i1,i2,i3;
            while (i+4 < b.Length)
            {
                b1 = a[b[i-1]-20];
                b2 = a[b[i]-20];
                b3 = a[b[i+1]-20];
                b4 = a[b[i+2]-20];

                i1 = (b1 << 2) | (b2 >> 4);
                i2 = ((b2 & 0xf) << 4) | (b3 >> 2);
                i3 = ((b3 & 3) << 6) | b4;

                result = result + /*'>'+*/Convert.ToChar(i1)+Convert.ToChar(i2)+Convert.ToChar(i3);
                i = i+4;
            }
            return result;
        }
0
 

Author Comment

by:valvet
ID: 17764242
Excellent job.

Workes like a charm.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question