/*
 * %Z%%W% %I%
 * ===========================================================================
 * Licensed Materials - Property of IBM
 * "Restricted Materials of IBM"
 *
 * IBM SDK, Java(tm) 2 Technology Edition, v1.4
 * (C) Copyright IBM Corp. 1999, 2002. All Rights Reserved
 * ===========================================================================
 */
/*
 * ConverterList: List and data for Converters
 *
 * Version:  1.4.1    11 Sept 2002
 *
 * Function:
 *     This provides a simple interface to compensate for the fact
 *     that Java does not have any APIs to return the list of
 *     supported Converters.
 *
 * Types:
 *     The Converter type is a 4 byte String.  The first character is:
 *     A - ASCII based single byte
 *     D - PC Style double byte
 *     d - PC Style DBCS-only
 *     E - EBCDIC based single byte
 *     H - EBCDIC double byte
 *     h - EBCDIC DBCS-only
 *     U - Unicode
 *     X - EUC multi-byte
 *     x - EUC DBCS-only
 *     2 - ISO 2022 based
 *     j - JIS base
 *
 *     The second byte is
 *     c - CECP EBCDIC
 *     e - EBCDIC
 *     i - ISO 8859 based
 *     m - Macintoch single byte
 *     p - PC codepage
 *     s - Stanard codepage
 *     w - Windows codepage
 *
 *     The third and forth bytes represent the region which is an iso language
 *     code or one of the following:
 *     cy = Cyrillic
 *     gb = United Kingdom
 *     l1 = Latin 1
 *     l2 = Latin 2
 *     l3 = Latin 3
 *     tw = Taiwan
 *     ww = Worldwide
 *
 * Todo:
 *     iso2022 not fully supported
 */
import java.lang.*;
import java.util.*;
import java.io.*;

public class ConverterList extends Object implements Enumeration {
    private  int    Count;
    private  int    Current;
    private  int    Last;
    private  int    SetFor;
    private  boolean [] leadByte;
    private  int    CType;
    private  boolean PreMark;
    private  boolean DbcsOnly;

    public static  final  int IBM       = 0;
    public static  final  int Windows   = 1;

    private static  final  int SBCS_TYPE   = 1;
    private static  final  int DBCS_TYPE   = 2;
    private static  final  int UTF8_TYPE   = 3;
    private static  final  int DBCS_EBCDIC = 4;
    private static  final  int EUCJP_TYPE  = 5;
    private static  final  int EUCTW_TYPE  = 6;
    private static  final  int GB18030_TYPE= 7;


    private static final int columns = 6;

    /**
     * Allocates a new <code>ConverterList</code> with default search criteria.
     */
    public ConverterList() {
        Count = Converters.length / columns;
        Last  = Count - 1;
        Current = -1;
        SetFor  = -2;
    }


    /**
     * Return the count of entries in the ConverterList
     */
    public int getCount() {
        return Count;
    }

    /**
     * Return the name of the currently selected converter.  If there is
     * no selected converter, return null.
     */
    public String getName() {
        if (Current>=0 && Current<Count)
            return Converters[Current*columns];
        return "";
    }

    /**
     * Return true if there is at least one additional entry in the list
     */
    public boolean hasMoreElements() {
        return Count<Last;
    }

    /**
     * Return the next entry in the converter list
     */
    public Object nextElement() {
        while (Current < Last) {
            Current++;
            return Converters[Current*columns];
        }
        throw new NoSuchElementException();
    }

    /**
     * Return the description of the current entry, no an empty string
     * if there is no current converter.
     */
    public String getDescription() {
        if (Current>=0 && Current<Count)
            return Converters[Current*columns + 4];
        return "";
    }

    /**
     * Return the description of the converter specified by the name.
     */
    public static String getDescription(String name) {
        int count = Converters.length / columns;
        for (int i=0; i<count; i++) {
            if (name.equals(Converters[i*columns]))
                return Converters[i*columns + 4];
        }
        return "";
    }

    /**
     * Return the notes for the current entry, no an empty string
     * if there is no current converter.
     */
    public String getNotes() {
        if (Current>=0 && Current<Count)
            return Converters[Current*columns + 5];
        return "";
    }

    /**
     * Return the notes for the converter specified by the name.
     */
    public static String getNotes(String name) {
        int count = Converters.length / columns;
        for (int i=0; i<count; i++) {
            if (name.equals(Converters[i*columns]))
                return Converters[i*columns + 5];
        }
        return "";
    }

    /**
     * Return the type of the current converter
     */
    public String getType() {
        if (Current>=0 && Current<Count)
            return Converters[Current*columns + 1];
        return "";
    }

    /**
     * Return the type of the converter specified by the name
     */
    public static String getType(String name) {
        int count = Converters.length / columns;
        for (int i=0; i<count; i++) {
            if (name.equals(Converters[i*columns]))
                return Converters[i*columns + 1];
        }
        return "";
    }

    /**
     * Get the codepage number associated with the curent converter.
     * Return zero if there is no current converter or the converter
     * does not have an associated
     */
    public int getCodepage(int kind) {
        if (kind != IBM && kind != Windows)
            return 0;
        if (Current>=0 && Current<Count)
            try {
                int ret = Integer.parseInt(Converters[Current*columns + 2+kind]);
                return ret>0 ? ret : 0;
            } catch (Exception e) {
                return 0;
            }
        return 0;
    }

    /**
     * Get the codepage number associated with the named converter.
     */
    public static int getCodepage(String name, int kind) {
        if (kind != IBM && kind != Windows)
            return 0;
        int count = Converters.length / columns;
        for (int i=0; i<count; i++) {
            if (name.equals(Converters[i*columns]))
                try {
                    int ret = Integer.parseInt(Converters[i*columns + 2+kind]);
                    return ret>0 ? ret : 0;
                } catch (Exception e) {
                    return 0;
                }
        }
        return 0;
    }

    /**
     * Get the converter name assoicated with a specified codepage.
     * Return an empty string if there is not converter matching the
     * specified codepage.
     */
    public static String getConverter(int codepage, int kind) {
        if (kind != IBM && kind != Windows)
            return "";
        if (codepage < 0)
            return "";
        int count = Converters.length / columns;
        String val = String.valueOf(codepage);
        for (int i=0; i<count; i++) {
            if (val.equals(Converters[i*columns + 2+kind]))
                return Converters[i*columns];
        }
        return "";
    }


    /**
     * Set the converter to use for subsequent operations
     */
    public String setConverter(String name) {
        int count = Converters.length / columns;
        for (int i=0; i<count; i++) {
            if (name.equals(Converters[i*columns])) {
                try {
                    byte [] byte1 = new byte[1];
                    byte1[0] = ' ';
                    String s = new String(byte1, name);
                    Current = i;
                    return Converters[i*columns];
                } catch (UnsupportedEncodingException exob) {
                }
            }
        }
        /* Try for alias */
        Current = -1;
        return "";
    }


    /**
     * Get an array of 256 UTF-32 characters at the start of this codepage
     */
    public int [] getChars() {
        return getChars(0);
    }


    private int byteCount(int where) {
        if (where == 0)
            return 0;
        if (where <= 0x100)
            return 1;
        if (where < 0x10000)
            return 2;
        return 3;
    }


    /**
     * Get an array of 256 UTF-32 characters at the specified position in this codepage
     */
    public int [] getChars(int where) {
        setupConverter();
        int  i, shift;
        boolean [] leadb = getLeadByte(where);
        int  len = byteCount(where);

        String encname = getName();

        byte [] byte1 = new byte[len+1];
        for (i=0, shift=8*(len-1); i<len; i++) {
            byte1[i] = (byte)((where >> shift) & 0xff);
            shift -= 8;
        }

        int [] vector = new int[256];
        for (i=0; i<256; i++) {
            if (leadb[i])
                vector[i] = 0xfffe;
            else {
                byte1[len] = (byte)i;
                try {
                    String s = new String(byte1, encname);
                    switch (s.length()) {
                    case 0: vector[i] = 0xffff;       break;
                    case 1: vector[i] = s.charAt(0);  break;
                    case 2: vector[i] = (((s.charAt(0)&0x03ff) << 10) | (s.charAt(1)&0x3ff))+0x10000;  break;
                    }
                    if (vector[i] == 0xfffd)
                        vector[i] = 0xffff;   /* Unassigned      */
                } catch (Exception e){
                    vector[i] = 0xffff;
                }
            }
        }
        return vector;
    }


    /**
     * Get the lead bytes at the specified location
     */
    public boolean [] getLeadByte(int where) {

        setupConverter();

        if (where == 0)
            return leadByte;

        boolean [] leadb = new boolean[256];
        switch (CType) {
        case UTF8_TYPE:
            if ((where >= 0xe0 && where <= 0xf7) ||
                (where >= 0xf080 && where <= 0xf7bf)) {
                setLead(leadb, 0x80, 0xBF);
            }
            break;
        case GB18030_TYPE:
            if (where >= 0x81 && where <= 0xfe)
                setLead(leadb, 0x30, 0x39);
            if (where >= 0x8130 && where <= 0xfe39)
                setLead(leadb, 0x81, 0xfe);
            break;
        case DBCS_EBCDIC:
            if (where == 0x0e) {
                setLead(leadb, 0x41, 0xFE);
                leadb[0x7f] = false;
            }
            break;
        case EUCJP_TYPE:
            if (where == 0x8F)
                setLead(leadb, 0xA1, 0xFE);
            break;
        case EUCTW_TYPE:
            if (where == 0x8E) {
                setLead(leadb, 0xA2, 0xB0);
            } else if (where >= 0x8fa2 && where <= 0x8fb0) {
                setLead(leadb, 0xA1, 0xFE);
            }
        }
        return leadb;
    }


    /**
     * Return the lead byte array at the start of the codepage
     */
    public boolean [] getLeadByte() {
        return getLeadByte(0);
    }


    /**
     * Set the first position in the converter
     */
    public int firstPosition() {
        setupConverter();
        if (DbcsOnly)
            return nextPosition(0);
        return 0;
    }


    /**
     * Given a position, find the next position to display
     */
    public int nextPosition(int where) {
        int i;

        setupConverter();

        if (CType==SBCS_TYPE)
            return 0;

        if (where==0) {
            if (leadByte[0])
                return 0x100;
            for (i=1; i<256; i++) {
                if (leadByte[i])
                    return i;
            }
            return 0;
        }

        boolean [] leadb = getLeadByte(where>>8);
        for (i=(where&0xff)+1; i<256; i++) {
            if (leadb[i]) {
                return (where&0xffff00) | i;
            }
        }
        return nextPosition(where>>8);

    }


    /**
     * Given a position, find the previous position to display
     */
    public int prevPosition(int where) {
        int i;

        setupConverter();

        if (CType==SBCS_TYPE || where==0)
            return 0;

        boolean [] leadb = getLeadByte(where>>8);
        for (i=(where&0xff)-1; i>=0; i--) {
            if (leadb[i]) {
                if (i == 0)
                    return 0x100;
                return (where&0xffff00) | i;
            }
        }
        return prevPosition(where>>8);
    }


    /**
     * Specify the new position given a selection
     */
    public int selectPosition(int where, int pos) {
        setupConverter();

        if (where == 0) {
            return leadByte[pos] ? (pos!=0 ? pos : 0x100) : 0;
        }
        return getLeadByte(where)[pos] ? ((where<<8)| pos) : 0;
    }

    private void setupConverter() {
        if (SetFor == Current || Current < 0 || Current >= Count)
            return;

        leadByte = new boolean [256];
        DbcsOnly = false;
        SetFor = Current;
        String type = getType();
        String lang = "";
        if (type.length() >= 4)
            lang = type.substring(2, 4);

        /*
         * Determine the converter type and lead byte range
         */
        int enctype = type.charAt(0);
        switch (enctype) {
        case '2':
        case 'E':
        case 'A':
            CType = SBCS_TYPE;
            return;

        case 'd':
            DbcsOnly = true;
        case 'D':
            CType = DBCS_TYPE;
            if (lang.equals("ja")) {
                setLead(0x81, 0x9f);
                setLead(0xe0, 0xfc);
            } else if (getName().equals("Cp1381") || getName().equals("Cp1380")) {
                setLead(0x8c, 0xfe);
            } else if (getName().equals("Cp949") || getName().equals("Cp949C") || getName().equals("MS949")) {
                setLead(0x8d, 0xfe);
            } else {
                setLead(0x81, 0xfe);
            }
            break;
        case 'G':
            CType = GB18030_TYPE;
            setLead(0x81, 0xfe);
            break;

        case 'U':
            if (type.length() > 1 && type.charAt(1)=='8') {
                setLead(0xC2, 0xf7);
                CType = UTF8_TYPE;
            } else {
                CType = DBCS_TYPE;
                setLead(0x00, 0xff);
                if (getName().equals("Unicode"))
                    PreMark = true;
            }
            break;

        case 'h':
            DbcsOnly = true;
        case 'H':
            CType = DBCS_EBCDIC;
            setLead(0x0e, 0x0e);
            break;

        case 'x':
            DbcsOnly = true;
        case 'X':
            CType = DBCS_TYPE;
            setLead(0xa1, 0xfe);
            if (lang.equals("ja")) {
                CType = EUCJP_TYPE;
                setLead(0x8e, 0x8f);
            }
            if (lang.equals("tw")) {
                setLead(0x8e, 0x8e);
                CType = EUCTW_TYPE;
            }
            break;


        case 'j':
            CType = DBCS_TYPE;
            setLead(0x21, 0x7e);
            break;
        }


    }

    private void setLead(boolean [] lead, int min, int max) {
        for (int i=min; i<=max; i++) {
            lead[i] = true;
        }
    }


    private void setLead(int min, int max) {
        setLead(leadByte, min, max);
    }


    static final String [] Converters = {
        "ASCII",           "Sien", "367",  "",      "ASCII 7 bit",                     "",
        "Big5",            "Dstw", "",     "",      "PC Taiwan Big 5",                 "",
        "COMPOUND_TEXT",   "2iww", "",     "",      "X11 Compound Text",               "ibm 1.4.01 nio",
        "Cp037",           "Ecus", "37",   "37",    "EBCDIC United States",            "",
        "Cp273",           "Ecde", "273",  "",      "EBCDIC Germany",                  "",
        "Cp277",           "Ecdk", "277",  "",      "EBCDIC Denmark, Norway",          "",
        "Cp278",           "Ecfi", "278",  "",      "EBCDIC Finland, Sweden",          "",
        "Cp280",           "Ecit", "280",  "",      "EBCDIC Italy ",                   "",
        "Cp284",           "Eces", "284",  "",      "EBCDIC Spain, Latin America",     "",
        "Cp285",           "Ecgb", "285",  "",      "EBCDIC UK, Ireland",              "",
        "Cp290",           "Ecja", "290",  "",      "EBCDIC SBCS Japan Katakana",      "ibm 1.3",
        "Cp297",           "Ecfr", "297",  "",      "EBCDIC France",                   "",
        "Cp300",           "heja", "300",  "",      "EBCDIC DBCS-only Japan",          "ibm 1.3",
        "Cp301",           "dpja", "301",  "",      "PC DBCS-only Japan",              "ibm 1.3",
        "Cp420",           "Eear", "420",  "",      "EBCDIC Arabic",                   "",
        "Cp420S",          "Eear", "",     "",      "EBCDIC Arabic shaped",            "ibm 1.2",
        "Cp424",           "Eehe", "424",  "",      "EBCDIC Hebrew",                   "",
        "Cp437",           "Apen", "437",  "437",   "PC United States",                "",
        "Cp500",           "Eel1", "500",  "500",   "EBCDIC Latin 1",                  "",
        "Cp737",           "Apel", "",     "773",   "MS-DOS Greek",                    "",
        "Cp775",           "Aplt", "",     "775",   "MS-DOS Baltic Rim",               "",
        "Cp808",           "Apru", "",     "",      "PC Russian (euro)",               "ibm 1.4",
        "Cp833",           "Eeko", "833",  "",      "EBCDIC SBCS Korean",              "ibm 1.3",
        "Cp834",           "heko", "834",  "",      "EBCDIC DBCS-only Korean",         "ibm 1.3",
        "Cp835",           "hetw", "835",  "",      "EBCDIC DBCS-only Taiwan",         "ibm 1.3",
        "Cp836",           "Eezh", "836",  "",      "EBCDIC SBCS China",               "ibm 1.3",
        "Cp837",           "hezh", "837",  "",      "EBCDIC DBCS-only China",          "ibm 1.3",
        "Cp838",           "Eeth", "838",  "",      "EBCDIC Thai",                     "",
        "Cp850",           "Apl1", "",     "850",   "PC Latin 1",                      "",
        "Cp852",           "Apl2", "852",  "852",   "PC Latin 2",                      "",
        "Cp855",           "Apcy", "855",  "855",   "PC Cyrillic",                     "",
        "Cp856",           "Aphe", "856",  "856",   "PC Hebrew (old)",                 "",
        "Cp857",           "Aptr", "857",  "857",   "PC Latin 5",                      "",
        "Cp858",           "Apl1", "850",  "",      "PC Latin 1 (euro)",               "",
        "Cp859",           "Apl1", "859",  "",      "PC Latin 9",                      "ibm 1.2",
        "Cp860",           "Appt", "860",  "860",   "PC Portugal",                     "",
        "Cp861",           "Apis", "861",  "861",   "PC Iceland",                      "",
        "Cp862",           "Aphe", "",     "862",   "PC Israel",                       "",
        "Cp863",           "Apfr", "863",  "863",   "PC Canadian French ",             "",
        "Cp864",           "Apar", "",     "864",   "PC Arabic",                       "",
        "Cp864S",          "Apar", "864",  "864",   "PC Arabic (shaped)",              "ibm 1.2",
        "Cp865",           "Apdk", "865",  "865",   "PC Nordic",                       "",
        "Cp866",           "Apru", "866",  "866",   "PC Russia",                       "",
        "Cp867",           "Aphe", "862",  "",      "PC Israel",                       "ibm 1.2",
        "Cp868",           "Apur", "868",  "",      "PC Urdu",                         "",
        "Cp869",           "Apel", "869",  "869",   "PC Greece",                       "",
        "Cp870",           "Eel2", "870",  "",      "EBCDIC Latin 2",                  "",
        "Cp871",           "Eeis", "871",  "",      "EBCDIC Iceland",                  "",
        "Cp874",           "Apth", "874",  "",      "PC Thai",                         "",
        "Cp875",           "Eeel", "875",  "875",   "EBCDIC Greek",                    "",
        "Cp897",           "Apja", "897",  "",      "PC SBCS-only Japan",              "ibm 1.3",
        "Cp918",           "Eeur", "918",  "",      "EBCDIC Urdu",                     "",
        "Cp921",           "Aplt", "921",  "",      "PC Baltic",                       "",
        "Cp922",           "Apet", "922",  "",      "PC Estonian",                     "",
        "Cp923",           "Apl1", "923",  "",      "PC Latin 9",                      "",
        "Cp924",           "Eel1", "924",  "",      "EBCDIC Latin 9",                  "ibm 1.2",
        "Cp927",           "dptw", "927",  "",      "PC DBCS-only Taiwan",             "ibm 1.3",
        "Cp930",           "Heja", "930",  "",      "EBCDIC Japan DBCS",               "",
        "Cp933",           "Heko", "933",  "",      "EBCDIC Korea DBCS",               "",
        "Cp935",           "Hezh", "935",  "",      "EBCDIC China DBCS",               "",
        "Cp937",           "Hetw", "937",  "",      "EBCDIC Taiwan DBCS",              "",
        "Cp939",           "Heja", "939",  "",      "EBCDIC Japan Extended DBCS",      "",
        "Cp942",           "Dpja", "", "",          "PC Japan SJIS-78",                "",
        "Cp942C",          "Dpja", "942",  "",      "PC Japan SJIS-78 syntax",         "",
        "Cp943",           "Dpja", "", "",          "PC Japan SJIS-90",                "",
        "Cp943C",          "Dpja", "943",  "",      "PC Japan SJIS-90 syntax",         "",
        "Cp947",           "dptw", "", "",          "PC DBCS-only Taiwan",             "ibm 1.3",
        "Cp948",           "Dptw", "948",  "",      "PC Taiwan SAA",                   "",
        "Cp949",           "Dpko", "", "",          "PC Korea (KS)",                   "",
        "Cp949C",          "Dpko", "949",  "",      "PC Korea (KS)",                   "",
        "Cp950",           "Dptw", "950",  "",      "PC Taiwan",                       "",
        "Cp951",           "Apko", "", "",          "PC DBCS-only Korean",             "ibm 1.3",
        "Cp954",           "Xsja", "954",  "",      "EUC Japan (full)",                "ibm 1.4",
        "Cp954C",          "Xsja", "954",  "",      "EUC Japan (full)with syntax",     "ibm 1.4",
        "Cp964",           "Xstw", "964",  "",      "EUC Taiwan",                      "",
        "Cp970",           "Xsko", "970",  "",      "EUC Korea",                       "",
        "Cp971",           "Xsko", "", "",          "EUC DBCS-only Korean",            "ibm 1.3",
        "Cp1006",          "Aiur", "1006", "",      "ISO Urdu",                        "",
        "Cp1025",          "Eecy", "1025", "",      "EBCDIC Cyrillic",                 "",
        "Cp1026",          "Eetr", "1026", "1026",  "EBCDIC Latin 5 (Turkey)",         "",
        "Cp1027",          "Eeja", "",     "",      "EBCDIC SBCS Japan",               "ibm 1.3",
        "Cp1041",          "Aptw", "1041", "",      "PC SBCS-only Japan",              "ibm 1.3",
        "Cp1043",          "Aptw", "1043", "",      "PC SBCS-only Taiwan",             "ibm 1.3",
        "Cp1046",          "Eear", "", "",          "EBCDIC Arabic",                   "",
        "Cp1046S",         "Eear", "1046", "",      "EBCDIC Arabic (shaped)",          "ibm 1.2",
        "Cp1047",          "Eel1", "1047", "",      "EBCDIC Open Edition",             "ibm 1.2",
        "Cp1088",          "Apko", "1088", "",      "PC SBCS-only Korean KS",          "ibm 1.3",
        "Cp1097",          "Eefa", "",     "",      "EBCDIC Farsi",                    "",
        "Cp1098",          "Aifa", "1098", "",      "ISO Farsi",                       "",
        "Cp1112",          "Eelt", "1112", "",      "EBCDIC Baltic",                   "",
        "Cp1114",          "Eetw", "1114", "",      "PC SBCS-only Taiwan",             "ibm 1.3",
        "Cp1115",          "Eezh", "1115", "",      "PC SBCS-only China",              "ibm 1.3",
        "Cp1122",          "Eeet", "1122", "",      "EBCDIC Estonia",                  "",
        "Cp1123",          "Eeuk", "1123", "",      "EBCDIC Ukraine",                  "",
        "Cp1124",          "Apuk", "1124", "",      "PC Ukraine",                      "",
        "Cp1140",          "Eeen", "1140", "",      "EBCDIC United States (euro)",     "",
        "Cp1141",          "Eede", "1141", "",      "EBCDIC Germany (euro)",           "",
        "Cp1142",          "Eedk", "1142", "",      "EBCDIC Denmark, Norway (euro)",   "",
        "Cp1143",          "Eefi", "1143", "",      "EBCDIC Finland, Sweden (euro)",   "",
        "Cp1144",          "Eeit", "1144", "",      "EBCDIC Italy (euro)",             "",
        "Cp1145",          "Eees", "1145", "",      "EBCDIC Spain (euro)",             "",
        "Cp1146",          "Eegb", "1146", "",      "EBCDIC UK, Ireland (euro)",       "",
        "Cp1147",          "Eefr", "1147", "",      "EBCDIC France (euro)",            "",
        "Cp1148",          "Eel1", "1148", "",      "EBCDIC Multilingual (euro)",      "",
        "Cp1149",          "Eeis", "1149", "",      "EBCDIC Iceland",                  "",
        "Cp1250",          "Awl2", "1250", "1250",  "Windows Latin 2",                 "",
        "Cp1251",          "Awcy", "1251", "1251",  "Windows Cyrillic",                "",
        "Cp1252",          "Awl1", "1252", "1252",  "Windows Latin 1 ",                "",
        "Cp1253",          "Awel", "1253", "1253",  "Windows Greek",                   "",
        "Cp1254",          "Awtr", "1254", "1254",  "Windows Latin 5 (Turkey)",        "",
        "Cp1255",          "Awhe", "1255", "1255",  "Windows Hebrew",                  "",
        "Cp1256",          "Awar", "1256", "1256",  "Windows Arabic",                  "",
        "Cp1256S",         "Awar", "",     "",      "Windows Arabic (shaped)",         "ibm 1.2",
        "Cp1257",          "Awlt", "1257", "1257",  "Windows Latin 4 (Balttic)",       "",
        "Cp1258",          "Awvi", "1258", "1258",  "Windows Vietnamese",              "",
        "Cp1351",          "dpja", "", "",          "PC DBCS-only Japan",              "ibm 1.3",
        "Cp1362",          "dpko", "",     "",      "PC DBCS-only Korea KS extended",  "ibm 1.3",
        "Cp1363",          "Dpko", "",     "",      "PC Korea KS extended",            "ibm 1.2",
        "Cp1363C",         "Dpko", "1363", "",      "PC Korea KS extended (syntax)",   "ibm 1.2",
        "Cp1364",          "Heko", "1364", "",      "EBCDIC Korea KS extended",        "ibm 1.2",
        "Cp1370",          "Dptw", "1370", "",      "PC Taiwan (euro)",                "ibm 1.2",
        "Cp1371",          "Hetw", "1371", "",      "EBCDIC Taiwan (euro)",            "ibm 1.2",
        "Cp1380",          "dpzh", "",     "",      "PC DBCS-only China GB",           "ibm 1.3",
        "Cp1381",          "Dpzh", "1381", "",      "PC China GB",                     "",
        "Cp1382",          "xszh", "",     "",      "EUC DBCS-only China GB",          "ibm 1.3",
        "Cp1383",          "Xszh", "1383", "",      "EUC China",                       "",
        "Cp1385",          "dpzh", "",     "",      "PC DBCS-only China GBK",          "ibm 1.3",
        "Cp1386",          "Dpzh", "1386", "",      "PC China GBK",                    "ibm 1.2",
        "Cp1388",          "Hezh", "1388", "",      "EBCDIC China GBK",                "ibm 1.2",
        "Cp1390",          "Heja", "1390", "",      "EBCDIC Japan Katakana (euro)",    "ibm 1,2",
        "Cp1399",          "Heja", "1399", "",      "EBCDIC Japan Latin (euro)",       "ibm 1.2",
        "Cp33722",         "Xsja", "",     "",      "EUC Japan",                       "",
        "Cp33722C",        "Xsja", "",     "",      "EUC Japan syntax",                "ibm 1.2",
        "EUC_CN",          "Xszh", "",     "",      "EUC China",                       "",
        "EUC_JP",          "Xsja", "",     "",      "EUC Japan",                       "",
        "EUC_KR",          "Xsko", "",     "",      "EUC Korea",                       "",
        "EUC_TW",          "Xstw", "",     "",      "EUC Taiwan",                      "",
        "GBK",             "Dszh", "1386", "936",   "China GBK",                       "",
        "GB18030",         "Gszh", "",     "54936", "China GB18030",                   "ibm 1.2, sun 1.4",
        "ISCII91",         "Asin", "",     "",      "ISCII Hindi 91",                  "ibm 1.2, sun 1.4",
        "ISO2022JP",       "2ija", "",     "",      "ISO 2022 Japan",                  "",
        "ISO2022KR",       "2iko", "",     "",      "ISO 2022 Korea",                  "",
        "ISO2022CN",       "2itw", "",     "",      "ISO 2022 Traditional Chinese",    "",
        "ISO2022CN_GB",    "2izh", "",     "",      "ISO 2022 Simplified Chinese",     "",
        "ISO8859_1",       "Ail1", "819",  "",      "ISO Latin 1",                     "",
        "ISO8859_2",       "Ail2", "912",  "",      "ISO Latin 2 - Central Europe",    "",
        "ISO8859_3",       "Ail3", "913",  "",      "ISO Latin 3 - Latin/Esperanto",   "",
        "ISO8859_4",       "Ail4", "914",  "",      "ISO Latin 4 - Baltic",            "",
        "ISO8859_5",       "Aicy", "915",  "",      "ISO Cyrillic",                    "",
        "ISO8859_6",       "Aiar", "1089", "",      "ISO Arabic",                      "",
        "ISO8859_6S",      "Aiar", "",     "",      "ISO Arabic (shaped)",             "ibm 1.2",
        "ISO8859_7",       "Aiel", "813",  "",      "ISO Greek",                       "",
        "ISO8859_8",       "Aihe", "916",  "",      "ISO Hebrew",                      "",
        "ISO8859_9",       "Aitr", "920",  "",      "ISO Latin 5",                     "",
        "ISO8859_10",      "Aino", "",     "",      "ISO Latin 6 - Nordic",            "ibm 1.4.01",
        "ISO8859_13",      "Ailt", "",     "",      "ISO Latin 7 - Baltic Rim",        "1.4",
        "ISO8859_14",      "Aiuk", "",     "",      "ISO Latin 8 - Celtic",            "ibm 1.4.01",
        "ISO8859_15",      "Ail1", "923",  "",      "ISO Latin 9 - Euro",              "was ISO8859_15_FDIS before 1.4",
        "ISO8859_16",      "Airo", "",     "",      "ISO Romanian",                    "ibm 1.4.01",
        "JIS0201",         "Asja", "",     "",      "Japan JIS 0201 (katakana)",       "",
        "JIS0208",         "jsja", "",     "",      "Japan JIS 0208",                  "",
        "JIS0212",         "jsja", "",     "",      "Japan JIS 0212",                  "",
        "Johab",           "Xsko", "",     "",      "PC Korean Johab",                 "",
        "KOI8_R",          "Axru", "",     "",      "Internet Russia",                 "",
        "KOI8_RU",         "Axbe", "",     "",      "Internet Belarus",                "ibm 1.4.01",
        "KOI8_U",          "Axuk", "",     "",      "Internet Ukraine",                "ibm 1.4.01",
        "KSC5601",         "Xsko", "",     "",      "Korea KSC5601",                   "",
        "MS874",           "Awth", "",     "874",   "Windows Thai",                    "",
        "MS932",           "Dwja", "",     "932",   "Windows Japan",                   "",
        "MS936",           "Dwzh", "",     "936",   "Windows China",                   "",
        "MS949",           "Dwko", "",     "949",   "Windows Korea",                   "",
        "MS950",           "Dwtw", "",     "950",   "Windows Taiwan",                  "",
        "MacArabic",       "Amar", "",     "",      "Apple Arabic",                    "",
        "MacCentralEurope","Aml2", "1282", "10029", "Apple Central Europe",            "",
        "MacCroatian",     "Amhr", "",     "",      "Apple Croatian ",                 "",
        "MacCyrillic",     "Amcy", "1283", "10007", "Apple Cyrillic",                  "",
        "MacDingbat",      "Amww", "",     "",      "Apple Dingbat",                   "",
        "MacGreek",        "Amel", "1280", "10006", "Apple Greek",                     "",
        "MacHebrew",       "Amhe", "",     "",      "Apple Hebrew ",                   "",
        "MacIceland",      "Amis", "",     "10079", "Apple Iceland",                   "",
        "MacRoman",        "Aml1", "1275", "10000", "Apple Roman",                     "",
        "MacRomania",      "Amro", "",     "10029", "Apple Romania",                   "",
        "MacSymbol",       "Amww", "1038", "",      "Apple PostScript Symbol",         "",
        "MacThai",         "Amth", "",     "",      "Apple Thai",                      "",
        "MacTurkish",      "Amtr", "1281", "10081", "Apple Turkish",                   "",
        "MacUkraine",      "Amuk", "",     "",      "Apple Ukraine",                   "",
        "PTCP154",         "Axkz", "",     "",      "Cyrillic Asian",                  "ibm 1.4.01",
        "Roman8",          "Axl1", "",     "",      "HP Roman 8",                      "ibm 1.4",
        "SJIS",            "Dsja", "",     "",      "Shift JIS Japan",                 "",
        "TIS620",          "Asth", "",     "",      "PC Thailand",                     "",
        "UTF-16",          "U2ww", "",     "",      "Unicode UTF-16",                  "",
        "UTF-16BE",        "U2ww", "1200", "1200",  "Unicode UTF-16 Big-endian",       "",
        "UTF-16LE",        "U2ww", "",     "",      "Unicode UTF-16 Little-endian",    "",
        "UTF32",           "U4ww", "",     "",      "Unicode UTF-32",                  "ibm 1.4 nio",
        "UTF32BE",         "U4ww", "",     "",      "Unicode UTF-32 Big-endian",       "ibm 1.4 nio",
        "UTF32LE",         "U4ww", "",     "",      "Unicode UTF-32 Little-endian",    "ibm 1.4 nio",
        "UTF8",            "U8ww", "1208", "1208",  "Unicode UTF-8",                   "",
        "UTF8J",           "U8ww", "",     "",      "Unicode UTF-8 (Java)",              "ibm 1.4 nio",
        "UTF8X",           "U8ww", "",     "",      "Unicode UTF-8 (allow non-shortest)","ibm 1.4 nio",
        "CESU8",           "U8ww", "",     "",      "Unicode UTF-8 (without surrogates)","ibm 1.4 nio",
    };
}
