📄 muudecode.bas
字号:
Attribute VB_Name = "MUUDecode"
Public Function UUDecodeToFile(strUUCodeData As String, strFilePath As String)
Dim vDataLine As Variant
Dim vDataLines As Variant
Dim strDataLine As String
Dim intSymbols As Integer
Dim intFile As Integer
Dim strTemp As String
'
'remove begin marker
If Left$(strUUCodeData, 6) = "begin " Then
strUUCodeData = Mid$(strUUCodeData, InStr(1, strUUCodeData, vbLf) + 1)
End If
'
'remove end marker
If Right$(strUUCodeData, 5) = "end" + vbCrLf Then
strUUCodeData = Left$(strUUCodeData, Len(strUUCodeData) - 10)
End If
intFile = FreeFile
Open strFilePath For Binary As intFile
'Split encoded data to vDataLines array.
'Now each array member contains a line of encoded data
vDataLines = Split(strUUCodeData, vbCrLf)
For Each vDataLine In vDataLines
'Decode data line by line
'
strDataLine = CStr(vDataLine)
'Get quantity of symbols in a line
intSymbols = Asc(Left$(strDataLine, 1)) - 32
'remove first symbol that just informs
'about quantity of symbols
strDataLine = Mid$(strDataLine, 2)
'replace "`" with " "
strDataLine = Replace(strDataLine, "`", " ")
'Convert every 4-byte chunk to 3-byte chunk by
For i = 1 To Len(strDataLine) Step 4
'1 byte
strTemp = strTemp + Chr((Asc(Mid(strDataLine, i, 1)) - 32) * 4 + _
(Asc(Mid(strDataLine, i + 1, 1)) - 32) \ 16)
'2 byte
strTemp = strTemp + Chr((Asc(Mid(strDataLine, i + 1, 1)) Mod 16) * 16 + _
(Asc(Mid(strDataLine, i + 2, 1)) - 32) \ 4)
'3 byte
strTemp = strTemp + Chr((Asc(Mid(strDataLine, i + 2, 1)) Mod 4) * 64 + _
Asc(Mid(strDataLine, i + 3, 1)) - 32)
Next i
'
strTemp = Left(strTemp, intSymbols)
'write decoded line to the file
Put intFile, , strTemp
'clear buffer for next line
strTemp = ""
Next
Close intFile
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -