Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.zip

public abstract Class ZipEncodingHelper

extends Object
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8

Static helper functions for robustly encoding file names in ZIP files.

Field Summary

Modifier and TypeField and Description
pack-priv static final ZipEncoding

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ZipEncoding

Returns:

A ZIP encoding for the given encoding name.
getZipEncoding
(final Charset
The charset of the ZIP encoding. Specify null for the platform's default encoding.
charset
)

Instantiates a ZIP encoding.

public static ZipEncoding

Returns:

A ZIP encoding for the given encoding name.
getZipEncoding
(final String
The name of the ZIP encoding. Specify null for the platform's default encoding.
name
)

Instantiates a ZIP encoding.

pack-priv static ByteBuffer
growBufferBy(final ByteBuffer buffer, final int increment)

pack-priv static boolean
isUTF8(final Charset
If the given charset is null, then check the platform's default encoding.
charset
)

Tests whether a given encoding is UTF-8.

pack-priv static boolean
isUTF8(final String
If the given name is null, then check the platform's default encoding.
charsetName
)

Tests whether a given encoding is UTF-8.

private static boolean
isUTF8Alias(final String actual)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ZIP_ENCODING_UTF_8back to summary
pack-priv static final ZipEncoding ZIP_ENCODING_UTF_8

UTF-8.

Constructor Detail

ZipEncodingHelperback to summary
public ZipEncodingHelper()

Method Detail

getZipEncodingback to summary
public static ZipEncoding getZipEncoding(final Charset charset)

Instantiates a ZIP encoding. An NIO based character set encoder/decoder will be returned. As a special case, if the character set is UTF-8, the NIO encoder will be configured replace malformed and unmappable characters with '?'. This matches existing behavior from the older fallback encoder.

If the requested character set cannot be found, the platform default will be used instead.

Parameters
charset:Charset

The charset of the ZIP encoding. Specify null for the platform's default encoding.

Returns:ZipEncoding

A ZIP encoding for the given encoding name.

Since
1.26.0
getZipEncodingback to summary
public static ZipEncoding getZipEncoding(final String name)

Instantiates a ZIP encoding. An NIO based character set encoder/decoder will be returned. As a special case, if the character set is UTF-8, the NIO encoder will be configured replace malformed and unmappable characters with '?'. This matches existing behavior from the older fallback encoder.

If the requested character set cannot be found, the platform default will be used instead.

Parameters
name:String

The name of the ZIP encoding. Specify null for the platform's default encoding.

Returns:ZipEncoding

A ZIP encoding for the given encoding name.

growBufferByback to summary
pack-priv static ByteBuffer growBufferBy(final ByteBuffer buffer, final int increment)
isUTF8back to summary
pack-priv static boolean isUTF8(final Charset charset)

Tests whether a given encoding is UTF-8. If the given name is null, then check the platform's default encoding.

Parameters
charset:Charset

If the given charset is null, then check the platform's default encoding.

isUTF8back to summary
pack-priv static boolean isUTF8(final String charsetName)

Tests whether a given encoding is UTF-8. If the given name is null, then check the platform's default encoding.

Parameters
charsetName:String

If the given name is null, then check the platform's default encoding.

isUTF8Aliasback to summary
private static boolean isUTF8Alias(final String actual)