📄 iconvmetadata.java
字号:
/* IconvMetaData.java -- Copyright (C) 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package gnu.java.nio.charset.iconv;import java.util.HashMap;import java.util.Vector;/** * This is ugly glue. iconv doesn't have character metadata, * so we include it here. * * TODO: Add more charsets which GNU iconv and the JDK support which aren't * included here. * * @author Sven de Marothy */final class IconvMetaData{ /** * Map of names (and aliases) to metadata instances */ private static HashMap names; /** * Vector of MetaData instances */ private static Vector charsets; /** * Name to use with iconv (may differ from the nio canonical. */ private String iconvName; /** * Average number of bytes per char. */ private float averageBperC; /** * Maximum number of bytes per char. */ private float maxBperC; /** * Average number of chars per byte. */ private float averageCperB; /** * Maximum number of chars per byte. */ private float maxCperB; /** * NIO canonical name. */ private String nioCanonical; /** * Charset aliases. */ private String[] aliases; IconvMetaData(String nioCanonical, float averageBperC, float maxBperC, float averageCperB, float maxCperB, String[] aliases, String iconvName) { this.nioCanonical = nioCanonical; this.iconvName = iconvName; this.averageBperC = averageBperC; this.maxBperC = maxBperC; this.averageCperB = averageCperB; this.maxCperB = maxCperB; this.aliases = aliases; names.put(nioCanonical, this); names.put(iconvName, this); for (int i = 0; i < aliases.length; i++) names.put(aliases[i], this); charsets.add(this); } static Vector charsets() { return charsets; } String[] aliases() { return aliases; } String nioCanonical() { return nioCanonical; } String iconvName() { return iconvName; } float maxBytesPerChar() { return maxBperC; } float maxCharsPerByte() { return maxCperB; } float averageBytesPerChar() { return averageBperC; } float averageCharsPerByte() { return averageCperB; } static IconvMetaData get(String s) { return (IconvMetaData) names.get(s); } static void setup() { names = new HashMap(); charsets = new Vector(); new IconvMetaData("Big5", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { "big-5", "csBig5" }, "Big5"); new IconvMetaData("Big5-HKSCS", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { "big5-hkscs", "Big5_HKSCS", "big5hkscs" }, "Big5-HKSCS"); new IconvMetaData("EUC-CN", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { }, "EUC-CN"); new IconvMetaData("EUC-JP", 3.0f, 3.0f, 0.5f, 1.0f, new String[] { "eucjis", "x-eucjp", "csEUCPkdFmtjapanese", "eucjp", "Extended_UNIX_Code_Packed_Format_for_Japanese", "x-euc-jp", "euc_jp" }, "EUC-JP"); new IconvMetaData("EUC-KR", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { "ksc5601", "5601", "ksc5601_1987", "ksc_5601", "ksc5601-1987", "euc_kr", "ks_c_5601-1987", "euckr", "csEUCKR" }, "EUC-KR"); new IconvMetaData("EUC-TW", 4.0f, 4.0f, 2.0f, 2.0f, new String[] { "cns11643", "euc_tw", "euctw", }, "EUC-TW"); new IconvMetaData("GB18030", 4.0f, 4.0f, 1.0f, 2.0f, new String[] { "gb18030-2000", }, "GB18030"); new IconvMetaData("GBK", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { "GBK" }, "GBK"); new IconvMetaData("ISO-2022-CN-CNS", 4.0f, 4.0f, 2.0f, 2.0f, new String[] { "ISO2022CN_CNS" }, "ISO-2022-CN"); // will this work? new IconvMetaData("ISO-2022-CN-GB", 4.0f, 4.0f, 2.0f, 2.0f, new String[] { "ISO2022CN_GB" }, "ISO-2022-CN"); // same here? new IconvMetaData("ISO-2022-KR", 4.0f, 4.0f, 1.0f, 1.0f, new String[] { "ISO2022KR", "csISO2022KR" }, "ISO-2022-KR"); new IconvMetaData("ISO-8859-1", 1.0f, 1.0f, 1.0f, 1.0f, new String[] { "iso-ir-100", "ISO_8859-1", "latin1", "l1", "IBM819", "CP819", "csISOLatin1", "8859_1", "ISO8859_1", "ISO_8859_1", "ibm-819", "ISO_8859-1:1987", "819" }, "ISO-8859-1"); new IconvMetaData("ISO-8859-13", 1.0f, 1.0f, 1.0f, 1.0f, new String[] { "ISO8859_13", "8859_13", "ibm-921_P100-1995", "ibm-921", "iso_8859_13", "iso8859_13", "iso-8859-13", "8859_13",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -