2024-09-14This is caused by my coding error, not a bug. Please move it to the appropriate region or delete this post. Thank you.
Today, I tested the Packer related functions of version 6.12 B1, mainly to decompress the most common zip archives.An error occurred when using UncompressPackMemory or UncompressPackFile to decompress a zip archive containing Chinese characters.
The test samples are: abc123.zip and 测试123.zip
;------
The problems encountered are as follows:
abc123.zip is successfully decompressed, 测试123.zip fails to decompress, the error statement is:
Result = UncompressPackMemory(0, *UnpackID, filelen, fullfilename$)
result is equal to -1.
Code: Select all
;2024-09-14
;Result = UncompressPackMemory(0, *UnpackID, filelen, fullfilename$)
Result = UncompressPackMemory(0, *UnpackID, filelen)
Code: Select all
UseZipPacker()
Define file$ = "D:\20240731\测试123.zip"
Define filename$ =GetFilePart(file$, #PB_FileSystem_NoExtension)
Define fullfilename$ = "" , filetext$ = ""
Define filelen.i = 0 , Result.i = 0
Define *UnpackID
; Open the packed file
If OpenPack(0, file$, #PB_PackerPlugin_Zip)
; List all the entries
If ExaminePack(0)
While NextPackEntry(0)
Debug "Name: " + PackEntryName(0) + ", Size: " + PackEntrySize(0)
fullfilename$ = PackEntryName(0)
filelen = PackEntrySize(0)
If filename$ = GetFilePart(fullfilename$, #PB_FileSystem_NoExtension)
Debug "PathPart: " + GetPathPart(fullfilename$)
Debug "FilePart: " + GetFilePart(fullfilename$, #PB_FileSystem_NoExtension)
Debug "ExtensionPart: " + GetExtensionPart(fullfilename$)
Debug "filelen: " + filelen
Debug "---------------"
*UnpackID = AllocateMemory(filelen)
Debug "*UnpackID : " + Str(*UnpackID)
If *UnpackID
Result = UncompressPackMemory(0, *UnpackID, filelen, fullfilename$)
;Result = UncompressPackFile(0, "D:\20240731\" + GetFilePart(fullfilename$), fullfilename$)
Debug "result: " + result
If result > 0
filetext$ = PeekS(*UnpackID, filelen, #PB_Unicode)
Debug "filetext$ = " + filetext$
;CreateFile(0, "D:\20240731\" + GetFilePart(fullfilename$), #PB_Unicode)
;WriteString(0, filetext$, #PB_Unicode)
;CloseFile(0)
EndIf
EndIf
EndIf
Wend
EndIf
ClosePack(0)
Else
Debug "open file: " + file$ + " error! "
EndIf