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 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior 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
|
|
|
|
|
|
Re: plugin/Zip issue with UTF-8 and large files [message #60424 is a reply to message #60421] |
Sun, 07 January 2024 16:17 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior Contributor |
|
|
Klugier wrote on Sat, 06 January 2024 20:42Hello Tom,
Could you prepare a PR for the main repository with your changes? This will save us time, and it will allow code review. Also, while merging, you will have credit in the form of being a co-creator.
Klugier
Hi,
Sure, why not. I just need step-by-step instructions to do it. As for the credits, I'm not after them. I just want the feature to be part of u++.
Best regards,
Tom
|
|
|
|
Goto Forum:
Current Time: Sat May 04 04:25:06 CEST 2024
Total time taken to generate the page: 0.01896 seconds
|