Menu

#1245 ZIP structure reading: encoding problem

v3.0
closed
dtf (63)
2012-09-15
2008-06-16
No

Version: 3.0.4207.1.

Where is a problem with encoding while reading ZIP file structure in Microsoft.Deployment.Compression.Zip assembly. Analyzing ZipFileHeader.Read(Stream stream, bool central) method (ZipFormat.cs) and - file names and archive comment always fetches as UTF-8 strings. These strings must be retrivied as UTF-8 strings if UTF-8 names support flag is set to true, and as strings in current OEM codepage (as sample - CultureInfo.CurrentCulture.TextInfo.OEMCodePage) overwise. Fixed ZipFormat.cs as sample attached, it's tested at Russian OEM codepage successfully.

P.S. Thanks, WBR Alexander. Sorry for bad english.

Discussion

  • Alexander Kozlenko

    ZipFormat.cs as sample

     
  • Alexander Kozlenko

    Logged In: YES
    user_id=2120265
    Originator: YES

    Sorry for mistake in version: version is 3.0.4207.0

     
  • Alexander Kozlenko

    Logged In: YES
    user_id=2120265
    Originator: YES

    Sorry for mistake in version: version is 3.0.4207.0

     
  • Alexander Kozlenko

    Logged In: YES
    user_id=2120265
    Originator: YES

    Hi, thanks a lot for your response. But IMHO you made a mistake: if UTF-8 flag not set, default OEM codepage instead of default Windows codepage is used. In my sample (ru-RU) it must be 866 codepage instead of 1251. But "Encoding headerEncoding = ((this.flags | ZipFileFlags.UTF8) != 0 ? Encoding.UTF8 : Encoding.Default);" will use 1251 codepage. Why? As a sample: i'm use WinRAR archiver - it pack files at 866 codepage for my locale, second - Windows Vista (packing to ZIP archive from Explorer) - it also used 866 codepage at this locale, ICSharpCode.SharpZipLib - in this project also used OEM codepage properly.

    ...really, i think it must be as
    "Encoding headerEncoding = ((this.flags | ZipFileFlags.UTF8) != 0 ? Encoding.UTF8 : Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage));"

    Thanks, WBR Alexander.

     
  • Alexander Kozlenko

    Logged In: YES
    user_id=2120265
    Originator: YES

    Any response or solution? =)

     
MongoDB Logo MongoDB