ZipEncoding

interface ZipEncoding

An interface for encoders that do a pretty encoding of ZIP file names.

There are mostly two implementations, one that uses java.nio Charset and one implementation, which copes with simple 8 bit charsets, because java-1.4 did not support Cp437 in java.nio.

The main reason for defining an own encoding layer comes from the problems with String.getBytes, which encodes unknown characters as ASCII quotation marks ('?'). Quotation marks are per definition an invalid file name on some operating systems like Windows, which leads to ignored ZIP entries.

All implementations should implement this interface in a reentrant way.

Functions

Link copied to clipboard
abstract fun canEncode(name: String): Boolean
Check, whether the given string may be losslessly encoded using this encoding.
Link copied to clipboard
abstract fun decode(data: Array<Byte>): String
Link copied to clipboard
abstract fun encode(name: String): ByteBuffer
Encode a file name or a comment to a byte array suitable for storing it to a serialized zip entry.