jdk/src/share/classes/sun/io/ByteToCharJISAutoDetect.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 5785 5dfabe612d10
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 5785
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.io;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.UnsupportedEncodingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.nio.cs.ext.JISAutoDetect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
public class ByteToCharJISAutoDetect extends ByteToCharConverter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
    private final static int EUCJP_MASK = 0x01;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    private final static int SJIS2B_MASK = 0x02;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    private final static int SJIS1B_MASK = 0x04;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    private final static int EUCJP_KANA1_MASK = 0x08;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    private final static int EUCJP_KANA2_MASK = 0x10;
5785
5dfabe612d10 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
andrew
parents: 5506
diff changeset
    37
    private final static byte[] maskTable1 = JISAutoDetect.getByteMask1();
5dfabe612d10 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
andrew
parents: 5506
diff changeset
    38
    private final static byte[] maskTable2 = JISAutoDetect.getByteMask2();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private final static int SS2 = 0x8e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private final static int SS3 = 0x8f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    // SJISName is set to either "SJIS" or "MS932"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private String SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private String EUCJPName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private String convName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private ByteToCharConverter detectedConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private ByteToCharConverter defaultConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public ByteToCharJISAutoDetect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        SJISName = CharacterEncoding.getSJISName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        EUCJPName = CharacterEncoding.getEUCJPName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        defaultConv = new ByteToCharISO8859_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        defaultConv.subChars = subChars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        defaultConv.subMode = subMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    public int flush(char [] output, int outStart, int outEnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        throws MalformedInputException, ConversionBufferFullException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        badInputLength = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        if(detectedConv != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
             return detectedConv.flush(output, outStart, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
             return defaultConv.flush(output, outStart, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Character conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public int convert(byte[] input, int inOff, int inEnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                       char[] output, int outOff, int outEnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        throws UnknownCharacterException, MalformedInputException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
               ConversionBufferFullException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        int num = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        charOff = outOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        byteOff = inOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            if (detectedConv == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                int euckana = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                int ss2count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                int firstmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                int secondmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                int cnt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                boolean nonAsciiFound = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                for (cnt = inOff; cnt < inEnd; cnt++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                    firstmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                    secondmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                    int byte1 = input[cnt]&0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    int byte2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                    // TODO: should check valid escape sequences!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                    if (byte1 == 0x1b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                        convName = "ISO2022JP";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                    // Try to convert all leading ASCII characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    if ((nonAsciiFound == false) && (byte1 < 0x80)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                        if (charOff >= outEnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                            throw new ConversionBufferFullException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                        output[charOff++] = (char) byte1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                        byteOff++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                        num++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                    // We can no longer convert ASCII.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                    nonAsciiFound = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    firstmask = maskTable1[byte1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    if (byte1 == SS2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                        ss2count++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    if (firstmask != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                        if (cnt+1 < inEnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                            byte2 = input[++cnt] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                            secondmask = maskTable2[byte2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                            int mask = firstmask & secondmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                            if (mask == EUCJP_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                convName = EUCJPName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                            if ((mask == SJIS2B_MASK) || (mask == SJIS1B_MASK)
5785
5dfabe612d10 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
andrew
parents: 5506
diff changeset
   132
                                || (JISAutoDetect.canBeSJIS1B(firstmask) && secondmask == 0)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                            // If the first byte is a SS3 and the third byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                            // is not an EUC byte, it should be SJIS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                            // Otherwise, we can't determine it yet, but it's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                            // very likely SJIS. So we don't take the EUCJP CS3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                            // character boundary. If we tried both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                            // possibilities here, it might be able to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                            // determined correctly.
5785
5dfabe612d10 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
andrew
parents: 5506
diff changeset
   144
                            if ((byte1 == SS3) && JISAutoDetect.canBeEUCJP(secondmask)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                                if (cnt+1 < inEnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                    int nextbyte = input[cnt+1] & 0xff;
5785
5dfabe612d10 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
andrew
parents: 5506
diff changeset
   147
                                    if (! JISAutoDetect.canBeEUCJP(maskTable2[nextbyte]))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                                        convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                    convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                            }
5785
5dfabe612d10 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
andrew
parents: 5506
diff changeset
   152
                            if (JISAutoDetect.canBeEUCKana(firstmask, secondmask))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                euckana++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                            if ((firstmask & SJIS1B_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                if (nonAsciiFound && (convName == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    if ((euckana > 1) || (ss2count > 1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                        convName = EUCJPName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                        convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                if (convName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                        detectedConv = ByteToCharConverter.getConverter(convName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                        detectedConv.subChars = subChars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                        detectedConv.subMode = subMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    } catch (UnsupportedEncodingException e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                        detectedConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                        convName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        } catch (ConversionBufferFullException bufferFullException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                throw bufferFullException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            // If we fail to detect the converter needed for any reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            // use the default converter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            detectedConv = defaultConv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        // If we've converted all ASCII characters, then return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        if (byteOff == inEnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            return num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if(detectedConv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                num += detectedConv.convert(input, inOff + num, inEnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                            output, outOff + num, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                charOff = detectedConv.nextCharIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                byteOff = detectedConv.nextByteIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                badInputLength = detectedConv.badInputLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                num += defaultConv.convert(input, inOff + num, inEnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                           output, outOff + num, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                charOff = defaultConv.nextCharIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                byteOff = defaultConv.nextByteIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                badInputLength = defaultConv.badInputLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if(detectedConv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
             detectedConv.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
             detectedConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
             convName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
             defaultConv.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        charOff = byteOff = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public String getCharacterEncoding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return "JISAutoDetect";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        String s = getCharacterEncoding();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        if (detectedConv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            s += "[" + detectedConv.getCharacterEncoding() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            s += "[unknown]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}