W
William Morgan
this is the code for a uuedecode function.. it works but is kinda slow
is there a better way in .net?
thanks for looking..
Private Function DecodeString(ByVal InString As String, ByVal Bytes As
Long) As String
Dim OutString As String
Dim i As Long
Dim x0, x1, x2 As Long 'These are the chars that will be
spit out
Dim y0, y1, y2, y3 As Long 'These are what we got in
Try
For i = 1 To Len(InString) Step 4
y0 = Asc(Mid(InString, i, 1)) 'Get 4 chars and put
into 'y's
y1 = Asc(Mid(InString, i + 1, 1))
y2 = Asc(Mid(InString, i + 2, 1))
y3 = Asc(Mid(InString, i + 3, 1))
If (y0 = 96) Then y0 = 32 'If char is 96 then set to 2
If (y1 = 96) Then y1 = 32
If (y2 = 96) Then y2 = 32
If (y3 = 96) Then y3 = 32
x0 = ((y0 - 32) * 4) + ((y1 - 32) \ 16) 'Calculate the
3 chars
x1 = ((y1 Mod 16) * 16) + ((y2 - 32) \ 4)
x2 = ((y2 Mod 4) * 64) + (y3 - 32)
OutString = OutString + Chr(x0) + Chr(x1) + Chr(x2)
Next i
If Len(OutString) > Bytes Then
DecodeString = Microsoft.VisualBasic.Left(OutString,
Bytes)
Else
DecodeString = OutString
End If
Catch ex As Exception
End Try
Return DecodeString
End Function
is there a better way in .net?
thanks for looking..
Private Function DecodeString(ByVal InString As String, ByVal Bytes As
Long) As String
Dim OutString As String
Dim i As Long
Dim x0, x1, x2 As Long 'These are the chars that will be
spit out
Dim y0, y1, y2, y3 As Long 'These are what we got in
Try
For i = 1 To Len(InString) Step 4
y0 = Asc(Mid(InString, i, 1)) 'Get 4 chars and put
into 'y's
y1 = Asc(Mid(InString, i + 1, 1))
y2 = Asc(Mid(InString, i + 2, 1))
y3 = Asc(Mid(InString, i + 3, 1))
If (y0 = 96) Then y0 = 32 'If char is 96 then set to 2
If (y1 = 96) Then y1 = 32
If (y2 = 96) Then y2 = 32
If (y3 = 96) Then y3 = 32
x0 = ((y0 - 32) * 4) + ((y1 - 32) \ 16) 'Calculate the
3 chars
x1 = ((y1 Mod 16) * 16) + ((y2 - 32) \ 4)
x2 = ((y2 Mod 4) * 64) + (y3 - 32)
OutString = OutString + Chr(x0) + Chr(x1) + Chr(x2)
Next i
If Len(OutString) > Bytes Then
DecodeString = Microsoft.VisualBasic.Left(OutString,
Bytes)
Else
DecodeString = OutString
End If
Catch ex As Exception
End Try
Return DecodeString
End Function