Results 1 to 4 of 4

Thread: uuEncode

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870

    uuEncode

    Hi,
    Does anybody know how to convert a uu encoded zip file into a normal winzip file?

    Many thanks
    Nick
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Im working on it. hopefully have something for you soon.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Ok. Here you go. all you need to do is pass the string to uuEncode function and it will return a string of data that you can then just simply create a new file and fill it with. I wrote up both the decoder and encoder function in case you ever need both.

    VB Code:
    1. Public Class UUCodec
    2.     Public Function uuDecode(ByVal encodedString As String) As String
    3.         Dim decodedstring As String
    4.         Dim x As Long = encodedString.Length
    5.         Dim i As Long
    6.         Dim char1 As Double
    7.         Dim char2 As Double
    8.  
    9.         For i = 1 To x Step 4
    10.             char1 = Asc(encodedString.Substring(i - 1, 1))
    11.             char2 = Asc(encodedString.Substring(i, 1))
    12.             If char1 = 96 Then char1 = 32
    13.             If char2 = 96 Then char2 = 32
    14.             decodedstring = decodedstring & Chr(((char1 - 32) * 4) + (Convert.ToInt16((char2 - 32) \ 16)))
    15.             char1 = Asc(encodedString.Substring(i, 1))
    16.             char2 = Asc(encodedString.Substring(i + 1, 1))
    17.             If char1 = 96 Then char1 = 32
    18.             If char2 = 96 Then char2 = 32
    19.             decodedstring = String.Concat(decodedstring, Chr(((char1 Mod 16) * 16) + (char2 - 32) \ 4))
    20.             char1 = Asc(encodedString.Substring(i + 1, 1))
    21.             char2 = Asc(encodedString.Substring(i + 2, 1))
    22.             If char1 = 96 Then char1 = 32
    23.             If char2 = 96 Then char2 = 32
    24.             decodedstring = String.Concat(decodedstring, Chr(((char1 Mod 4) * 64) + (char2 - 32)))
    25.         Next
    26.  
    27.         Return decodedstring
    28.     End Function
    29.  
    30.     Public Function uuEncode(ByVal decodedString As String) As String
    31.         Dim encodedstring As String
    32.         Dim x As Long = decodedString.Length
    33.         Dim i As Long
    34.         Dim char1 As Double
    35.         Dim char2 As Double
    36.  
    37.         If x Mod 3 <> 0 Then
    38.             Dim temp As String = New String(Chr(0), 3 - x Mod 3)
    39.             encodedstring = String.Concat(encodedstring, temp)
    40.         End If
    41.  
    42.         For i = 1 To x Step 3
    43.             char1 = Asc(decodedString.Substring(i - 1, 1))
    44.             If char1 = 96 Then char1 = 32
    45.             encodedstring = String.Concat(encodedstring, Chr(char1 \ 4 + 32))
    46.             char1 = Asc(decodedString.Substring(i - 1, 1))
    47.             char2 = Asc(decodedString.Substring(i, 1))
    48.             If char1 = 96 Then char1 = 32
    49.             If char2 = 96 Then char2 = 32
    50.             encodedstring = String.Concat(encodedstring, Chr((((char1 Mod 4) * 16)) + (char2 \ 16 + 32)))
    51.             char1 = Asc(decodedString.Substring(i, 1))
    52.             char2 = Asc(decodedString.Substring(i + 1, 1))
    53.             If char1 = 96 Then char1 = 32
    54.             If char2 = 96 Then char2 = 32
    55.             encodedstring = String.Concat(encodedstring, Chr((((char1 Mod 16) * 4)) + (char2 \ 64 + 32)))
    56.             char1 = Asc(decodedString.Substring(i + 1, 1))
    57.             If char1 = 96 Then char1 = 32
    58.             encodedstring = String.Concat(encodedstring, Chr((((char1 Mod 64) + 32))))
    59.         Next
    60.         Return encodedstring
    61.     End Function
    62. End Class
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    Hi Cander,

    thanks for that. I've sent you a PM.

    Nick
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width