/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
uuencoding og decoding i vb 6
Fra : Thomas Nielsen


Dato : 11-01-02 08:43

Hej

Nogen der har en ide til hvordan man uuencoder og decoder i vb 6?

/Thomas



 
 
Jan V. (11-01-2002)
Kommentar
Fra : Jan V.


Dato : 11-01-02 10:42

"Thomas Nielsen" <thomas@websup.dk> skrev i en meddelelse
news:NKw%7.11$bZ2.811@news.get2net.dk...
> Hej
>
> Nogen der har en ide til hvordan man uuencoder og decoder i vb 6?
>
> /Thomas
>
>

Encode kan jeg da hjælpe med

Jan

Public Function UUEncodeFile(strFilePath As String) As String

Dim intFile As Integer 'file handler
Dim intTempFile As Integer 'temp file
Dim lFileSize As Long 'size of the file
Dim strFileName As String 'name of the file
Dim strFileData As String 'file data chunk
Dim lEncodedLines As Long 'number of encoded lines
Dim strTempLine As String 'temporary string
Dim i As Long 'loop counter
Dim j As Integer 'loop counter

Dim strResult As String
'
'Get file name
strFileName = Mid$(strFilePath, InStrRev(strFilePath, "\") + 1)
'
'Insert first marker: "begin 664 ..."
strResult = "begin 664 " + strFileName + vbLf
'
'Get file size
lFileSize = FileLen(strFilePath)
lEncodedLines = lFileSize \ 45 + 1
'
'Prepare buffer to retrieve data from
'the file by 45 symbols chunks
strFileData = Space(45)
'
intFile = FreeFile
'
Open strFilePath For Binary As intFile
For i = 1 To lEncodedLines
'Read file data by 45-bytes cnunks
'
If i = lEncodedLines Then
'Last line of encoded data often is not
'equal to 45, therefore we need to change
'size of the buffer
strFileData = Space(lFileSize Mod 45)
End If
'Retrieve data chunk from file to the buffer
Get intFile, , strFileData
'Add first symbol to encoded string that informs
'about quantity of symbols in encoded string.
'More often "M" symbol is used.
strTempLine = Chr(Len(strFileData) + 32)
'
If i = lEncodedLines And (Len(strFileData) Mod 3) Then
'If the last line is processed and length of
'source data is not a number divisible by 3, add one or two
'blankspace symbols
strFileData = strFileData + Space(3 - (Len(strFileData) Mod
3))
End If

For j = 1 To Len(strFileData) Step 3
'Breake each 3 (8-bits) bytes to 4 (6-bits) bytes
'
'1 byte
strTempLine = strTempLine + Chr(Asc(Mid(strFileData, j, 1))
\ 4 + 32)
'2 byte
strTempLine = strTempLine + Chr((Asc(Mid(strFileData, j, 1))
Mod 4) * 16 _
+ Asc(Mid(strFileData, j + 1, 1)) \ 16 + 32)
'3 byte
strTempLine = strTempLine + Chr((Asc(Mid(strFileData, j + 1,
1)) Mod 16) * 4 _
+ Asc(Mid(strFileData, j + 2, 1)) \ 64 + 32)
'4 byte
strTempLine = strTempLine + Chr(Asc(Mid(strFileData, j + 2,
1)) Mod 64 + 32)
Next j
'replace " " with "`"
strTempLine = Replace(strTempLine, " ", "`")
'add encoded line to result buffer
strResult = strResult + strTempLine + vbLf
'reset line buffer
strTempLine = ""
Next i
Close intFile

'add the end marker
strResult = strResult & "`" & vbLf + "end" + vbLf
'asign return value
UUEncodeFile = strResult

End Function




Thomas Nielsen (11-01-2002)
Kommentar
Fra : Thomas Nielsen


Dato : 11-01-02 11:43

"Jan V." <jv@miljodata.dk> wrote in message
news:3c3eb3c2$0$62848$edfadb0f@dspool01.news.tele.dk...

> Encode kan jeg da hjælpe med

Tak jan det virker perfekt.

Nu mangler jeg bare løsning på decondig af min filer.

/Thomas



Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408927
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste