U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » plugin/Zip issue with UTF-8
plugin/Zip issue with UTF-8 [message #60406] Wed, 03 January 2024 16:21 Go to previous message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

Just found a character encoding issue with plugin/Zip. When writing Zip files, the gpflag bit 11 should to be set for the filenames to be properly decoded by the reading program. (E.g. Windows 11 File Explorer incorrectly interprets the UTF-8 filenames written by plugin/Zip if the bit is not set.)

Please include the following fix:
void Zip::BeginFile(const char *path, Time tm, bool deflate)
{
	ASSERT(!IsFileOpened());
	if(deflate) {
		pipeZLib.Create();
		pipeZLib->WhenOut = THISBACK(PutCompressed);
		pipeZLib->GZip(false).CRC().NoHeader().Compress();
	}
	else {
		crc32.Clear();
		uncompressed = true;
	}
	File& f = file.Add();
	f.version = 21;
	f.gpflag = 0x8 | 1<<11; // Added UTF-8 marker, i.e.: " | 1<<11";
	f.method = deflate ? 8 : 0;
	f.crc = 0;
	f.csize = 0;
	f.usize = 0;
	FileHeader(path, tm);
	if (zip->IsError()) WhenError();
}


Found the gpflag bit to set here:

https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.0.TX T

Do not know if it is a safe site, but at least the bit to set was correct. Now Windows can read the filenames properly.

Best regards,

Tom
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: is memsetex really at optimal speed?
Next Topic: unsigned long / uint64 from Value type
Goto Forum:
  


Current Time: Tue Apr 28 10:35:50 GMT+2 2026

Total time taken to generate the page: 0.00537 seconds