Show / Hide Table of Contents

Class StringCodec

Utility class for resolving the encoding used for reading and writing strings

Inheritance
System.Object
StringCodec
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ICSharpCode.SharpZipLib.Zip
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class StringCodec

Fields

| Improve this Doc View Source

UnicodeZipEncoding

Returns the UTF-8 code page (65001) used for zip entries with unicode flag set

Declaration
public static readonly Encoding UnicodeZipEncoding
Field Value
Type Description
System.Text.Encoding
| Improve this Doc View Source

ZipSpecCodePage

The non-unicode code page that should be used according to the zip specification

Declaration
public const int ZipSpecCodePage = 437
Field Value
Type Description
System.Int32

Properties

| Improve this Doc View Source

CodePage

Code page used for non-unicode strings and legacy zip encoding (if ForceZipLegacyEncoding is set). Default value is SystemDefaultCodePage

Declaration
public int CodePage { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Default

Creates a StringCodec that uses the system default encoder or UTF-8 depending on whether the zip entry Unicode flag is set

Declaration
public static StringCodec Default { get; }
Property Value
Type Description
StringCodec
| Improve this Doc View Source

DefaultZipCryptoEncoding

The default encoding used for ZipCrypto passwords in zip files, set to SystemDefaultEncoding for greatest compability.

Declaration
public static Encoding DefaultZipCryptoEncoding { get; }
Property Value
Type Description
System.Text.Encoding
| Improve this Doc View Source

ForceZipLegacyEncoding

If set, use the encoding set by CodePage for zip entries instead of the defaults

Declaration
public bool ForceZipLegacyEncoding { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

LegacyEncoding

Code page encoding, used for non-unicode strings

Declaration
public Encoding LegacyEncoding { get; }
Property Value
Type Description
System.Text.Encoding
Remarks

The original Zip specification (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) states that file names should only be encoded with IBM Code Page 437 or UTF-8. In practice, most zip apps use OEM or system encoding (typically cp437 on Windows).

| Improve this Doc View Source

SystemDefaultCodePage

Operating system default codepage.

Declaration
public static int SystemDefaultCodePage { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

SystemDefaultEncoding

The system default encoding.

Declaration
public static Encoding SystemDefaultEncoding { get; }
Property Value
Type Description
System.Text.Encoding
| Improve this Doc View Source

ZipArchiveCommentEncoding

The encoding used for the zip archive comment. Defaults to the encoding for CodePage, since no unicode flag can be set for it in the files.

Declaration
public Encoding ZipArchiveCommentEncoding { get; }
Property Value
Type Description
System.Text.Encoding
| Improve this Doc View Source

ZipCryptoEncoding

The encoding used for the ZipCrypto passwords. Defaults to DefaultZipCryptoEncoding.

Declaration
public Encoding ZipCryptoEncoding { get; }
Property Value
Type Description
System.Text.Encoding
| Improve this Doc View Source

ZipOutputEncoding

Returns the encoding for an output ZipEntry. Unless overriden by ForceZipLegacyEncoding it returns UnicodeZipEncoding.

Declaration
public Encoding ZipOutputEncoding { get; }
Property Value
Type Description
System.Text.Encoding

Methods

| Improve this Doc View Source

FromCodePage(Int32)

Creates a StringCodec that uses an encoding from the specified code page except for zip entries with the Unicode flag

Declaration
public static StringCodec FromCodePage(int codePage)
Parameters
Type Name Description
System.Int32 codePage
Returns
Type Description
StringCodec
| Improve this Doc View Source

FromEncoding(Encoding)

Creates a StringCodec that uses an the specified encoding, except for zip entries with the Unicode flag

Declaration
public static StringCodec FromEncoding(Encoding encoding)
Parameters
Type Name Description
System.Text.Encoding encoding
Returns
Type Description
StringCodec
| Improve this Doc View Source

WithForcedLegacyEncoding()

Create a copy of this StringCodec that ignores the Unicode flag when reading entries

Declaration
public StringCodec WithForcedLegacyEncoding()
Returns
Type Description
StringCodec
| Improve this Doc View Source

WithStrictSpecEncoding()

Creates a StringCodec that uses the zip specification encoder or UTF-8 depending on whether the zip entry Unicode flag is set

Declaration
public static StringCodec WithStrictSpecEncoding()
Returns
Type Description
StringCodec
| Improve this Doc View Source

WithZipArchiveCommentEncoding(Encoding)

Create a copy of this StringCodec with the specified zip archive comment encoding

Declaration
public StringCodec WithZipArchiveCommentEncoding(Encoding commentEncoding)
Parameters
Type Name Description
System.Text.Encoding commentEncoding
Returns
Type Description
StringCodec
| Improve this Doc View Source

WithZipCryptoEncoding(Encoding)

Create a copy of this StringCodec with the specified zip crypto password encoding

Declaration
public StringCodec WithZipCryptoEncoding(Encoding cryptoEncoding)
Parameters
Type Name Description
System.Text.Encoding cryptoEncoding
Returns
Type Description
StringCodec
| Improve this Doc View Source

ZipEncoding(Boolean)

Returns UnicodeZipEncoding if unicode is set, otherwise it returns the encoding indicated by CodePage

Declaration
public Encoding ZipEncoding(bool unicode)
Parameters
Type Name Description
System.Boolean unicode
Returns
Type Description
System.Text.Encoding
| Improve this Doc View Source

ZipInputEncoding(GeneralBitFlags)

Returns the appropriate encoding for an input ZipEntry according to flags. If overridden by ForceZipLegacyEncoding, it always returns the encoding indicated by CodePage.

Declaration
public Encoding ZipInputEncoding(GeneralBitFlags flags)
Parameters
Type Name Description
GeneralBitFlags flags
Returns
Type Description
System.Text.Encoding
| Improve this Doc View Source

ZipInputEncoding(Int32)

Returns the appropriate encoding for an input ZipEntry according to flags. If overridden by ForceZipLegacyEncoding, it always returns the encoding indicated by CodePage.

Declaration
public Encoding ZipInputEncoding(int flags)
Parameters
Type Name Description
System.Int32 flags
Returns
Type Description
System.Text.Encoding
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2000-2022 SharpZipLib Contributors