/** * Instantiates a zip encoding. * * @param name The name of the zip encoding. Specify {@code null} for * the platform's default encoding. * @return A zip encoding for the given encoding name. */ public static ZipEncoding getZipEncoding(final String name) { // fallback encoding is good enough for utf-8. if (isUTF8(name)) { return UTF8_ZIP_ENCODING; } if (name == null) { return new FallbackZipEncoding(); } final SimpleEncodingHolder h = simpleEncodings.get(name); if (h != null) { return h.getEncoding(); } try { final Charset cs = Charset.forName(name); return new NioZipEncoding(cs); } catch (final UnsupportedCharsetException e) { return new FallbackZipEncoding(name); } }