jdk/src/share/classes/sun/io/ByteToCharJISAutoDetect.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2003 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    private static byte[] maskTable1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private static byte[] maskTable2;
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
    private final static JISAutoDetect nioCoder = new JISAutoDetect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    // SJISName is set to either "SJIS" or "MS932"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private String SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private String EUCJPName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private String convName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private ByteToCharConverter detectedConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private ByteToCharConverter defaultConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public ByteToCharJISAutoDetect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        SJISName = CharacterEncoding.getSJISName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        EUCJPName = CharacterEncoding.getEUCJPName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        defaultConv = new ByteToCharISO8859_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        defaultConv.subChars = subChars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        defaultConv.subMode = subMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        maskTable1 = nioCoder.getByteMask1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        maskTable2 = nioCoder.getByteMask2();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public int flush(char [] output, int outStart, int outEnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        throws MalformedInputException, ConversionBufferFullException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        badInputLength = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        if(detectedConv != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
             return detectedConv.flush(output, outStart, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
             return defaultConv.flush(output, outStart, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Character conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public int convert(byte[] input, int inOff, int inEnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                       char[] output, int outOff, int outEnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        throws UnknownCharacterException, MalformedInputException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
               ConversionBufferFullException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        int num = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        charOff = outOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        byteOff = inOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            if (detectedConv == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                int euckana = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                int ss2count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                int firstmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                int secondmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                int cnt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                boolean nonAsciiFound = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                for (cnt = inOff; cnt < inEnd; cnt++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                    firstmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                    secondmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                    int byte1 = input[cnt]&0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                    int byte2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    // TODO: should check valid escape sequences!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    if (byte1 == 0x1b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                        convName = "ISO2022JP";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                    // Try to convert all leading ASCII characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                    if ((nonAsciiFound == false) && (byte1 < 0x80)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                        if (charOff >= outEnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                            throw new ConversionBufferFullException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                        output[charOff++] = (char) byte1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                        byteOff++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                        num++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    // We can no longer convert ASCII.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    nonAsciiFound = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    firstmask = maskTable1[byte1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    if (byte1 == SS2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                        ss2count++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    if (firstmask != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                        if (cnt+1 < inEnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                            byte2 = input[++cnt] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                            secondmask = maskTable2[byte2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                            int mask = firstmask & secondmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                            if (mask == EUCJP_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                convName = EUCJPName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                            if ((mask == SJIS2B_MASK) || (mask == SJIS1B_MASK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                || (nioCoder.canBeSJIS1B(firstmask) && secondmask == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                            // If the first byte is a SS3 and the third byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                            // is not an EUC byte, it should be SJIS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                            // Otherwise, we can't determine it yet, but it's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                            // very likely SJIS. So we don't take the EUCJP CS3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                            // character boundary. If we tried both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                            // possibilities here, it might be able to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                            // determined correctly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                            if ((byte1 == SS3) && nioCoder.canBeEUCJP(secondmask)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                if (cnt+1 < inEnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                    int nextbyte = input[cnt+1] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                    if (! nioCoder.canBeEUCJP(maskTable2[nextbyte]))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                        convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                    convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                            if (nioCoder.canBeEUCKana(firstmask, secondmask))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                euckana++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                            if ((firstmask & SJIS1B_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                if (nonAsciiFound && (convName == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    if ((euckana > 1) || (ss2count > 1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                        convName = EUCJPName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                        convName = SJISName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                if (convName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                        detectedConv = ByteToCharConverter.getConverter(convName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                        detectedConv.subChars = subChars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                        detectedConv.subMode = subMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    } catch (UnsupportedEncodingException e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                        detectedConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                        convName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        } catch (ConversionBufferFullException bufferFullException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                throw bufferFullException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            // If we fail to detect the converter needed for any reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            // use the default converter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            detectedConv = defaultConv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        // If we've converted all ASCII characters, then return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (byteOff == inEnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            return num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if(detectedConv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                num += detectedConv.convert(input, inOff + num, inEnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                            output, outOff + num, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                charOff = detectedConv.nextCharIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                byteOff = detectedConv.nextByteIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                badInputLength = detectedConv.badInputLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                num += defaultConv.convert(input, inOff + num, inEnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                           output, outOff + num, outEnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                charOff = defaultConv.nextCharIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                byteOff = defaultConv.nextByteIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                badInputLength = defaultConv.badInputLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if(detectedConv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
             detectedConv.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
             detectedConv = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
             convName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
             defaultConv.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        charOff = byteOff = 0;
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 getCharacterEncoding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return "JISAutoDetect";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        String s = getCharacterEncoding();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (detectedConv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            s += "[" + detectedConv.getCharacterEncoding() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            s += "[unknown]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
}