Recent

Author Topic: Unit Zipper from package paszlib has an inconsistency  (Read 2496 times)

tetrastes

  • Full Member
  • ***
  • Posts: 117
Re: Unit Zipper from package paszlib has an inconsistency
« Reply #30 on: April 28, 2021, 12:43:30 pm »
This has nothing to do with zipper. It is a standard problem in FPC string handling. If you use zipper in an LCL GUI program everything works fine because the standard encoding is UTF8. The problem mentioned appears in standalone commandline programs in which FPC does not switch to UTF8 by default.

Simply call SetMultiByteConversionCodePage(CP_UTF8) as the first line of your program and the zipper handles utf8-encoded file names correctly. See also attached demo.

Have you tested generated by your demo test.zip? 

wp

  • Hero Member
  • *****
  • Posts: 8348
Re: Unit Zipper from package paszlib has an inconsistency
« Reply #31 on: April 28, 2021, 12:56:11 pm »
Yes, of course. But I use PowerArchiver to display the zip rather than 7zip, and it displays the directory correctly. And the unzipped folder contains the alpha-beta-gamma.txt file - did you look in the "unzipped" folder? (And alpha, beta, gamma are not on my Windows code page).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

tetrastes

  • Full Member
  • ***
  • Posts: 117
Re: Unit Zipper from package paszlib has an inconsistency
« Reply #32 on: April 28, 2021, 01:37:08 pm »
The unzipped folder contains the αβγ.txt file only if test.zip unzipped with your demo (i.e. zipper.pp) and may be with PowerArchiver, and may be smth else, which supposes that filenames in archive in utf8. But this is not what Windows uses for filenames. And other unzippers will unzip it to ╬▒╬▓╬│.txt.   

wp

  • Hero Member
  • *****
  • Posts: 8348
Re: Unit Zipper from package paszlib has an inconsistency
« Reply #33 on: April 28, 2021, 04:43:33 pm »
ok, I see it in the Win Explorer now. But after some seeking I found that there is a TZipper property UseLanguageEncoding which, when set to true, writes the archive names in UTF8 encoding.

There is also a UseUTF8 property for the Unzipper, but I did not find it necessary to set it to true. Also, calling the SetMultiByteConversionCodepage was not required any more after activating the UseLanguageEncoding property.

Oh man - I think the paszlib wiki page in which zipper is documented needs a rewrite...
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

 

TinyPortal © 2005-2018