Class ZipEncodingHelper
java.lang.Object
org.apache.commons.compress.archivers.zip.ZipEncodingHelper
Static helper functions for robustly encoding file names in ZIP files.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ZipEncodinggetZipEncoding(String name) Instantiates a ZIP encoding.static ZipEncodinggetZipEncoding(Charset charset) Instantiates a ZIP encoding.(package private) static ByteBuffergrowBufferBy(ByteBuffer buffer, int increment) (package private) static booleanTests whether a given encoding is UTF-8.private static booleanisUTF8Alias(String name) Tests whether the given non-null charset name is a UTF-8 alias.private static CharsettoSafeCharset(String name) Returns a Charset for the named charset.
-
Field Details
-
ZIP_ENCODING_UTF_8
UTF-8.
-
-
Constructor Details
-
ZipEncodingHelper
public ZipEncodingHelper()
-
-
Method Details
-
getZipEncoding
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- The charset of the ZIP encoding. Specifynullfor the platform's default encoding.- Returns:
- A ZIP encoding for the given encoding name.
- Since:
- 1.26.0
-
getZipEncoding
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- The name of the ZIP encoding. Specifynullfor the platform's default encoding.- Returns:
- A ZIP encoding for the given encoding name.
-
growBufferBy
-
isUTF8
Tests whether a given encoding is UTF-8. If the given name is null, then check the platform's default encoding.- Parameters:
charset- If the given charset is null, then check the platform's default encoding.
-
isUTF8Alias
Tests whether the given non-null charset name is a UTF-8 alias.- Parameters:
name- a non-null charset name.- Returns:
- whether the given non-null charset name is a UTF-8 alias.
-
toSafeCharset
Returns a Charset for the named charset. If the name cannot find a charset, returnCharset.defaultCharset().- Parameters:
name- The name of the requested charset, may be null.- Returns:
- a Charset for the named charset.
- See Also:
-