[fpc-pascal] TZipper and special file names like "atenção.txt" (#26213)
silvioprog
silvioprog at gmail.com
Fri May 23 20:32:31 CEST 2014
2014-05-23 13:28 GMT-03:00 Michael Van Canneyt <michael at freepascal.org>:
>
> On Fri, 23 May 2014, Tomas Hajny wrote:
>
>> On Fri, May 23, 2014 17:38, Reinier Olislagers wrote:
>>
>>> On 23/05/2014 17:30, Michael Van Canneyt wrote:
>>>
>>>> On Fri, 23 May 2014, silvioprog wrote:
>>>
>>> I have a program that makes daily backups, and just discovered this
>>>>> problem when I noticed that it did not compressing files with names
>>>>> with special characters.
>>>>>
>>>>
>>>> This is not fixable. The zip standard has no rules for encoding
>>>> filenames.
>>>> Whatever bytes you put in is what comes out.
>>>> You are entirely responsible for handling the encoding.
>>>>
>>>
>>> Not quite, according to the spec
>>> http://www.pkware.com/documents/casestudies
>>
>>
>> I can't access this URL (HTTP 403 - Forbidden). The right URL seems to be
>> http://www.pkware.com/documents/casestudies/APPNOTE.TXT.
>>
>
> Indeed.
>
> A proper implementation would require a serious rewrite of this component
> with a unicode API. This can be entered as a feature request if so desired.
Nice. I can do it, opening a new issue in bugtracker.
Temporarily, I fixed my problem 'underlining' the file name, e.g.:
program project1;
{$mode objfpc}{$H+}
uses
zipper, zstream, sysutils, RUtils {
https://github.com/silvioprog/rutils/blob/master/src/rutils.pas };
var
dir, fil, fn, zip: string;
begin
dir := 'C:\Silvio Clécio\Cópias de segurança\';
fn := 'instrução-para-desbloqueio-do-PIN.pdf';
fil := dir + fn;
zip := dir + RUtils.UnderlineStr(fn + '.zip');
with TZipper.Create do
try
FileName :=
{$IFDEF MSWINDOWS}Utf8ToAnsi({$ENDIF}zip{$IFDEF MSWINDOWS}){$ENDIF};
Entries.AddFileEntry(
{$IFDEF MSWINDOWS}Utf8ToAnsi({$ENDIF}fil{$IFDEF MSWINDOWS}){$ENDIF},
RUtils.UnderlineStr(fn)).CompressionLevel := clMax;
ZipAllFiles;
finally
Free;
end;
end.
Thanks!
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140523/59a61427/attachment.html>
More information about the fpc-pascal
mailing list