jdk/src/share/classes/sun/nio/cs/ext/ISCII91.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 3714 6a4eb8f53f91
child 10343 2359f68b67c8
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
     2
 * Copyright (c) 2002, 2006, 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: 3714
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: 3714
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: 3714
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
package sun.nio.cs.ext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.nio.charset.Charset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.nio.CharBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.nio.ByteBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.nio.charset.CharsetDecoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.nio.charset.CharsetEncoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.nio.charset.CoderResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.nio.cs.Surrogate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.nio.cs.HistoricallyNamedCharset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public class ISCII91 extends Charset implements HistoricallyNamedCharset
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static final char NUKTA_CHAR = '\u093c';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private static final char HALANT_CHAR = '\u094d';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static final byte NO_CHAR = (byte)255;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public ISCII91() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        super("x-ISCII91", ExtendedCharsets.aliasesFor("x-ISCII91"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public String historicalName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        return "ISCII91";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public boolean contains(Charset cs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        return ((cs.name().equals("US-ASCII"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                || (cs instanceof ISCII91));
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 CharsetDecoder newDecoder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        return new Decoder(this);
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 CharsetEncoder newEncoder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return new Encoder(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private static final char[] directMapTable = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        '\u0000', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        '\u0001', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        '\u0002', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        '\u0003', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        '\u0004', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        '\u0005', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        '\u0006', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        '\u0007', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        '\u0008', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        '\u0009', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        '\012', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        '\u000b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        '\u000c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        '\015', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        '\u000e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        '\u000f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        '\u0010', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        '\u0011', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        '\u0012', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        '\u0013', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        '\u0014', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        '\u0015', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        '\u0016', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        '\u0017', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        '\u0018', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        '\u0019', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        '\u001a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        '\u001b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        '\u001c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        '\u001d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        '\u001e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        '\u001f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        '\u0020', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        '\u0021', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        '\u0022', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        '\u0023', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        '\u0024', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        '\u0025', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        '\u0026', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        (char)0x0027, // '\u0027' control -- ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        '\u0028', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        '\u0029', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        '\u002a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        '\u002b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        '\u002c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        '\u002d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        '\u002e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        '\u002f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        '\u0030', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        '\u0031', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        '\u0032', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        '\u0033', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        '\u0034', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        '\u0035', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        '\u0036', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        '\u0037', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        '\u0038', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        '\u0039', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        '\u003a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        '\u003b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        '\u003c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        '\u003d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        '\u003e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        '\u003f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        '\u0040', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        '\u0041', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        '\u0042', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        '\u0043', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        '\u0044', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        '\u0045', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        '\u0046', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        '\u0047', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        '\u0048', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        '\u0049', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        '\u004a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        '\u004b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        '\u004c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        '\u004d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        '\u004e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        '\u004f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        '\u0050', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        '\u0051', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        '\u0052', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        '\u0053', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        '\u0054', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        '\u0055', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        '\u0056', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        '\u0057', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        '\u0058', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        '\u0059', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        '\u005a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        '\u005b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        '\\',// '\u005c' -- ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        '\u005d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        '\u005e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        '\u005f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        '\u0060', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        '\u0061', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        '\u0062', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        '\u0063', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        '\u0064', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        '\u0065', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        '\u0066', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        '\u0067', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        '\u0068', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        '\u0069', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        '\u006a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        '\u006b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        '\u006c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        '\u006d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        '\u006e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        '\u006f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        '\u0070', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        '\u0071', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        '\u0072', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        '\u0073', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        '\u0074', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        '\u0075', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        '\u0076', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        '\u0077', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        '\u0078', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        '\u0079', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        '\u007a', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        '\u007b', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        '\u007c', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        '\u007d', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        '\u007e', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        '\u007f', // ascii character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        '\uffff', // unknown character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        '\u0901', // a1 -- Vowel-modifier CHANDRABINDU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        '\u0902', // a2 -- Vowel-modifier ANUSWAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        '\u0903', // a3 -- Vowel-modifier VISARG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        '\u0905', // a4 -- Vowel A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        '\u0906', // a5 -- Vowel AA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        '\u0907', // a6 -- Vowel I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        '\u0908', // a7 -- Vowel II
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        '\u0909', // a8 -- Vowel U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        '\u090a', // a9 -- Vowel UU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        '\u090b', // aa -- Vowel RI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        '\u090e', // ab -- Vowel E ( Southern Scripts )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        '\u090f', // ac -- Vowel EY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        '\u0910', // ad -- Vowel AI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        '\u090d', // ae -- Vowel AYE ( Devanagari Script )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        '\u0912', // af -- Vowel O ( Southern Scripts )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        '\u0913', // b0 -- Vowel OW
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        '\u0914', // b1 -- Vowel AU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        '\u0911', // b2 -- Vowel AWE ( Devanagari Script )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        '\u0915', // b3 -- Consonant KA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        '\u0916', // b4 -- Consonant KHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        '\u0917', // b5 -- Consonant GA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        '\u0918', // b6 -- Consonant GHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        '\u0919', // b7 -- Consonant NGA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        '\u091a', // b8 -- Consonant CHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        '\u091b', // b9 -- Consonant CHHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        '\u091c', // ba -- Consonant JA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        '\u091d', // bb -- Consonant JHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        '\u091e', // bc -- Consonant JNA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        '\u091f', // bd -- Consonant Hard TA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        '\u0920', // be -- Consonant Hard THA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        '\u0921', // bf -- Consonant Hard DA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        '\u0922', // c0 -- Consonant Hard DHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        '\u0923', // c1 -- Consonant Hard NA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        '\u0924', // c2 -- Consonant Soft TA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        '\u0925', // c3 -- Consonant Soft THA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        '\u0926', // c4 -- Consonant Soft DA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        '\u0927', // c5 -- Consonant Soft DHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        '\u0928', // c6 -- Consonant Soft NA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        '\u0929', // c7 -- Consonant NA ( Tamil )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        '\u092a', // c8 -- Consonant PA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        '\u092b', // c9 -- Consonant PHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        '\u092c', // ca -- Consonant BA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        '\u092d', // cb -- Consonant BHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        '\u092e', // cc -- Consonant MA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        '\u092f', // cd -- Consonant YA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        '\u095f', // ce -- Consonant JYA ( Bengali, Assamese & Oriya )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        '\u0930', // cf -- Consonant RA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        '\u0931', // d0 -- Consonant Hard RA ( Southern Scripts )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        '\u0932', // d1 -- Consonant LA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        '\u0933', // d2 -- Consonant Hard LA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        '\u0934', // d3 -- Consonant ZHA ( Tamil & Malayalam )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        '\u0935', // d4 -- Consonant VA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        '\u0936', // d5 -- Consonant SHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        '\u0937', // d6 -- Consonant Hard SHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        '\u0938', // d7 -- Consonant SA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        '\u0939', // d8 -- Consonant HA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        '\u200d', // d9 -- Consonant INVISIBLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        '\u093e', // da -- Vowel Sign AA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        '\u093f', // db -- Vowel Sign I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        '\u0940', // dc -- Vowel Sign II
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        '\u0941', // dd -- Vowel Sign U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        '\u0942', // de -- Vowel Sign UU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        '\u0943', // df -- Vowel Sign RI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        '\u0946', // e0 -- Vowel Sign E ( Southern Scripts )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        '\u0947', // e1 -- Vowel Sign EY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        '\u0948', // e2 -- Vowel Sign AI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        '\u0945', // e3 -- Vowel Sign AYE ( Devanagari Script )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        '\u094a', // e4 -- Vowel Sign O ( Southern Scripts )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        '\u094b', // e5 -- Vowel Sign OW
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        '\u094c', // e6 -- Vowel Sign AU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        '\u0949', // e7 -- Vowel Sign AWE ( Devanagari Script )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        '\u094d', // e8 -- Vowel Omission Sign ( Halant )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        '\u093c', // e9 -- Diacritic Sign ( Nukta )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        '\u0964', // ea -- Full Stop ( Viram, Northern Scripts )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        '\uffff', // eb -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        '\uffff', // ec -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        '\uffff', // ed -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        '\uffff', // ee -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        '\ufffd', // ef -- Attribute Code ( ATR )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        '\ufffd', // f0 -- Extension Code ( EXT )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        '\u0966', // f1 -- Digit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        '\u0967', // f2 -- Digit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        '\u0968', // f3 -- Digit 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        '\u0969', // f4 -- Digit 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        '\u096a', // f5 -- Digit 4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        '\u096b', // f6 -- Digit 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        '\u096c', // f7 -- Digit 6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        '\u096d', // f8 -- Digit 7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        '\u096e', // f9 -- Digit 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        '\u096f', // fa -- Digit 9
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        '\uffff', // fb -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        '\uffff', // fc -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        '\uffff', // fd -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        '\uffff', // fe -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        '\uffff'  // ff -- This position shall not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }; //end of table definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * This accessor is temporarily supplied while sun.io
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * converters co-exist with the sun.nio.cs.{ext} charset coders
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * These facilitate sharing of conversion tables between the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * two co-existing implementations. When sun.io converters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * are made extinct these will be unnecessary and should be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    public static char[] getDirectMapTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        return directMapTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    private static final byte[] encoderMappingTable = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    NO_CHAR,NO_CHAR, //0900 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    (byte)161,NO_CHAR, //0901 -- DEVANAGARI SIGN CANDRABINDU = anunasika
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    (byte)162,NO_CHAR, //0902 -- DEVANAGARI SIGN ANUSVARA = bindu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    (byte)163,NO_CHAR, //0903 -- DEVANAGARI SIGN VISARGA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    NO_CHAR,NO_CHAR, //0904 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    (byte)164,NO_CHAR, //0905 -- DEVANAGARI LETTER A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    (byte)165,NO_CHAR, //0906 -- DEVANAGARI LETTER AA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    (byte)166,NO_CHAR, //0907 -- DEVANAGARI LETTER I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    (byte)167,NO_CHAR, //0908 -- DEVANAGARI LETTER II
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    (byte)168,NO_CHAR, //0909 -- DEVANAGARI LETTER U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    (byte)169,NO_CHAR, //090a -- DEVANAGARI LETTER UU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    (byte)170,NO_CHAR, //090b -- DEVANAGARI LETTER VOCALIC R
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    (byte)166,(byte)233, //090c -- DEVANAGARI LETTER VOVALIC L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    (byte)174,NO_CHAR, //090d -- DEVANAGARI LETTER CANDRA E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    (byte)171,NO_CHAR, //090e -- DEVANAGARI LETTER SHORT E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    (byte)172,NO_CHAR, //090f -- DEVANAGARI LETTER E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    (byte)173,NO_CHAR, //0910 -- DEVANAGARI LETTER AI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    (byte)178,NO_CHAR, //0911 -- DEVANAGARI LETTER CANDRA O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    (byte)175,NO_CHAR, //0912 -- DEVANAGARI LETTER SHORT O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    (byte)176,NO_CHAR, //0913 -- DEVANAGARI LETTER O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    (byte)177,NO_CHAR, //0914 -- DEVANAGARI LETTER AU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    (byte)179,NO_CHAR, //0915 -- DEVANAGARI LETTER KA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    (byte)180,NO_CHAR, //0916 -- DEVANAGARI LETTER KHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    (byte)181,NO_CHAR, //0917 -- DEVANAGARI LETTER GA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    (byte)182,NO_CHAR, //0918 -- DEVANAGARI LETTER GHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    (byte)183,NO_CHAR, //0919 -- DEVANAGARI LETTER NGA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    (byte)184,NO_CHAR, //091a -- DEVANAGARI LETTER CA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    (byte)185,NO_CHAR, //091b -- DEVANAGARI LETTER CHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    (byte)186,NO_CHAR, //091c -- DEVANAGARI LETTER JA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    (byte)187,NO_CHAR, //091d -- DEVANAGARI LETTER JHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    (byte)188,NO_CHAR, //091e -- DEVANAGARI LETTER NYA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    (byte)189,NO_CHAR, //091f -- DEVANAGARI LETTER TTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    (byte)190,NO_CHAR, //0920 -- DEVANAGARI LETTER TTHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    (byte)191,NO_CHAR, //0921 -- DEVANAGARI LETTER DDA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    (byte)192,NO_CHAR, //0922 -- DEVANAGARI LETTER DDHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    (byte)193,NO_CHAR, //0923 -- DEVANAGARI LETTER NNA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    (byte)194,NO_CHAR, //0924 -- DEVANAGARI LETTER TA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    (byte)195,NO_CHAR, //0925 -- DEVANAGARI LETTER THA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    (byte)196,NO_CHAR, //0926 -- DEVANAGARI LETTER DA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    (byte)197,NO_CHAR, //0927 -- DEVANAGARI LETTER DHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    (byte)198,NO_CHAR, //0928 -- DEVANAGARI LETTER NA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    (byte)199,NO_CHAR, //0929 -- DEVANAGARI LETTER NNNA <=> 0928 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    (byte)200,NO_CHAR, //092a -- DEVANAGARI LETTER PA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    (byte)201,NO_CHAR, //092b -- DEVANAGARI LETTER PHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    (byte)202,NO_CHAR, //092c -- DEVANAGARI LETTER BA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    (byte)203,NO_CHAR, //092d -- DEVANAGARI LETTER BHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    (byte)204,NO_CHAR, //092e -- DEVANAGARI LETTER MA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    (byte)205,NO_CHAR, //092f -- DEVANAGARI LETTER YA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    (byte)207,NO_CHAR, //0930 -- DEVANAGARI LETTER RA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    (byte)208,NO_CHAR, //0931 -- DEVANAGARI LETTER RRA <=> 0930 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    (byte)209,NO_CHAR, //0932 -- DEVANAGARI LETTER LA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    (byte)210,NO_CHAR, //0933 -- DEVANAGARI LETTER LLA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    (byte)211,NO_CHAR, //0934 -- DEVANAGARI LETTER LLLA <=> 0933 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    (byte)212,NO_CHAR, //0935 -- DEVANAGARI LETTER VA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    (byte)213,NO_CHAR, //0936 -- DEVANAGARI LETTER SHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    (byte)214,NO_CHAR, //0937 -- DEVANAGARI LETTER SSA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    (byte)215,NO_CHAR, //0938 -- DEVANAGARI LETTER SA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    (byte)216,NO_CHAR, //0939 -- DEVANAGARI LETTER HA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    NO_CHAR,NO_CHAR, //093a <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    NO_CHAR,NO_CHAR, //093b <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    (byte)233,NO_CHAR, //093c -- DEVANAGARI SIGN NUKTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    (byte)234,(byte)233, //093d -- DEVANAGARI SIGN AVAGRAHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    (byte)218,NO_CHAR, //093e -- DEVANAGARI VOWEL SIGN AA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    (byte)219,NO_CHAR, //093f -- DEVANAGARI VOWEL SIGN I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    (byte)220,NO_CHAR, //0940 -- DEVANAGARI VOWEL SIGN II
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    (byte)221,NO_CHAR, //0941 -- DEVANAGARI VOWEL SIGN U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    (byte)222,NO_CHAR, //0942 -- DEVANAGARI VOWEL SIGN UU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    (byte)223,NO_CHAR, //0943 -- DEVANAGARI VOWEL SIGN VOCALIC R
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    (byte)223,(byte)233, //0944 -- DEVANAGARI VOWEL SIGN VOCALIC RR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    (byte)227,NO_CHAR, //0945 -- DEVANAGARI VOWEL SIGN CANDRA E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    (byte)224,NO_CHAR, //0946 -- DEVANAGARI VOWEL SIGN SHORT E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    (byte)225,NO_CHAR, //0947 -- DEVANAGARI VOWEL SIGN E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    (byte)226,NO_CHAR, //0948 -- DEVANAGARI VOWEL SIGN AI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    (byte)231,NO_CHAR, //0949 -- DEVANAGARI VOWEL SIGN CANDRA O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    (byte)228,NO_CHAR, //094a -- DEVANAGARI VOWEL SIGN SHORT O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    (byte)229,NO_CHAR, //094b -- DEVANAGARI VOWEL SIGN O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    (byte)230,NO_CHAR, //094c -- DEVANAGARI VOWEL SIGN AU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    (byte)232,NO_CHAR, //094d -- DEVANAGARI SIGN VIRAMA ( halant )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    NO_CHAR,NO_CHAR, //094e <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    NO_CHAR,NO_CHAR, //094f <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    (byte)161,(byte)233, //0950 -- DEVANAGARI OM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    (byte)240,(byte)181, //0951 -- DEVANAGARI STRESS SIGN UDATTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    (byte)240,(byte)184, //0952 -- DEVANAGARI STRESS SIGN ANUDATTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    (byte)254,NO_CHAR, //0953 -- DEVANAGARI GRAVE ACCENT || MISSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    (byte)254,NO_CHAR, //0954 -- DEVANAGARI ACUTE ACCENT || MISSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    NO_CHAR,NO_CHAR, //0955 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    NO_CHAR,NO_CHAR, //0956 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    NO_CHAR,NO_CHAR, //0957 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    (byte)179,(byte)233, //0958 -- DEVANAGARI LETTER QA <=> 0915 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    (byte)180,(byte)233, //0959 -- DEVANAGARI LETTER KHHA <=> 0916 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    (byte)181,(byte)233, //095a -- DEVANAGARI LETTER GHHA <=> 0917 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    (byte)186,(byte)233, //095b -- DEVANAGARI LETTER ZA <=> 091C + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    (byte)191,(byte)233, //095c -- DEVANAGARI LETTER DDDHA <=> 0921 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    (byte)192,(byte)233, //095d -- DEVANAGARI LETTER RHA <=> 0922 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    (byte)201,(byte)233, //095e -- DEVANAGARI LETTER FA <=> 092B + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    (byte)206,NO_CHAR, //095f -- DEVANAGARI LETTER YYA <=> 092F + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    (byte)170,(byte)233, //0960 -- DEVANAGARI LETTER VOCALIC RR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    (byte)167,(byte)233, //0961 -- DEVANAGARI LETTER VOCALIC LL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    (byte)219,(byte)233, //0962 -- DEVANAGARI VOWEL SIGN VOCALIC L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    (byte)220,(byte)233, //0963 -- DEVANAGARI VOWEL SIGN VOCALIC LL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    (byte)234,NO_CHAR, //0964 -- DEVANAGARI DANDA ( phrase separator )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    (byte)234,(byte)234, //0965 -- DEVANAGARI DOUBLE DANDA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    (byte)241,NO_CHAR, //0966 -- DEVANAGARI DIGIT ZERO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    (byte)242,NO_CHAR, //0967 -- DEVANAGARI DIGIT ONE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    (byte)243,NO_CHAR, //0968 -- DEVANAGARI DIGIT TWO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    (byte)244,NO_CHAR, //0969 -- DEVANAGARI DIGIT THREE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    (byte)245,NO_CHAR, //096a -- DEVANAGARI DIGIT FOUR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    (byte)246,NO_CHAR, //096b -- DEVANAGARI DIGIT FIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    (byte)247,NO_CHAR, //096c -- DEVANAGARI DIGIT SIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    (byte)248,NO_CHAR, //096d -- DEVANAGARI DIGIT SEVEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    (byte)249,NO_CHAR, //096e -- DEVANAGARI DIGIT EIGHT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    (byte)250,NO_CHAR, //096f -- DEVANAGARI DIGIT NINE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    (byte)240,(byte)191,  //0970 -- DEVANAGARI ABBREVIATION SIGN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    NO_CHAR,NO_CHAR, //0971 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    NO_CHAR,NO_CHAR, //0972 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    NO_CHAR,NO_CHAR, //0973 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    NO_CHAR,NO_CHAR, //0974 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    NO_CHAR,NO_CHAR, //0975 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    NO_CHAR,NO_CHAR, //0976 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    NO_CHAR,NO_CHAR, //0977 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    NO_CHAR,NO_CHAR, //0978 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    NO_CHAR,NO_CHAR, //0979 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    NO_CHAR,NO_CHAR, //097a -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    NO_CHAR,NO_CHAR, //097b -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    NO_CHAR,NO_CHAR, //097c -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    NO_CHAR,NO_CHAR, //097d -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    NO_CHAR,NO_CHAR, //097e -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    NO_CHAR,NO_CHAR  //097f -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }; //end of table definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * This accessor is temporarily supplied while sun.io
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * converters co-exist with the sun.nio.cs.{ext} charset coders
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * These facilitate sharing of conversion tables between the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * two co-existing implementations. When sun.io converters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * are made extinct these will be unnecessary and should be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public static byte[] getEncoderMappingTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return encoderMappingTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    private static class Decoder extends CharsetDecoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        private static final char ZWNJ_CHAR = '\u200c';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        private static final char ZWJ_CHAR = '\u200d';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        private static final char INVALID_CHAR = '\uffff';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        private char contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        private boolean needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        private Decoder(Charset cs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            super(cs, 1.0f, 1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        protected CoderResult implFlush(CharBuffer out) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                if (out.remaining() < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                    return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    out.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        /*Rules:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
         * 1)ATR,EXT,following character to be replaced with '\ufffd'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
         * 2)Halant + Halant => '\u094d' (Virama) + '\u200c'(ZWNJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
         * 3)Halant + Nukta => '\u094d' (Virama) + '\u200d'(ZWJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        private CoderResult decodeArrayLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                                             CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            byte[] sa = src.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            int sp = src.arrayOffset() + src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            int sl = src.arrayOffset() + src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            assert (sp <= sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            sp = (sp <= sl ? sp : sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            char[] da = dst.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            int dp = dst.arrayOffset() + dst.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            int dl = dst.arrayOffset() + dst.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            assert (dp <= dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            dp = (dp <= dl ? dp : dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                while (sp < sl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                    int index = sa[sp];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                    index = ( index < 0 )? ( index + 255 ):index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                    char currentChar = directMapTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                    // if the contextChar is either ATR || EXT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                    // set the output to '\ufffd'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                    if(contextChar == '\ufffd') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                        da[dp++] = '\ufffd';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                        contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                        needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                    switch(currentChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                    case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                    case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                    case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                    case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                    case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                    case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                    case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                            if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                        contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                        needFlushing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                    case NUKTA_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                        switch(contextChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                        case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                            da[dp++] = '\u0950';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                        case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                            da[dp++] = '\u090c';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                        case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                            da[dp++] = '\u0961';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                        case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                            da[dp++] = '\u0960';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                        case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                            da[dp++] = '\u0962';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                            da[dp++] = '\u0963';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                        case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                            da[dp++] = '\u0944';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                        case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                            da[dp++] = '\u093d';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                        case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                                da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                                sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                            da[dp++] = ZWJ_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                                da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                                sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                            da[dp++] = NUKTA_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                    case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                        if(contextChar == HALANT_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                            da[dp++] = ZWNJ_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                        da[dp++] = HALANT_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                    case INVALID_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                            if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                        da[dp++] = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                    }//end switch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
           } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                src.position(sp - src.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                dst.position(dp - dst.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        private CoderResult decodeBufferLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                                             CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            int mark = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                while (src.hasRemaining()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                    int index = src.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                    index = ( index < 0 )? ( index + 255 ):index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                    char currentChar = directMapTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                    // if the contextChar is either ATR || EXT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                    // set the output to '\ufffd'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                    if(contextChar == '\ufffd') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                        dst.put('\ufffd');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                        contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                        needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                        mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                    switch(currentChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                    case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                    case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                    case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                    case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                    case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                            if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                        contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                        needFlushing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                        mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                    case NUKTA_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                        switch(contextChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                        case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                            dst.put('\u0950');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                        case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                            dst.put('\u090c');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                        case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                            dst.put('\u0961');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                        case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                            dst.put('\u0960');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                        case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                            dst.put('\u0962');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                        case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                            dst.put('\u0963');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                        case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                            dst.put('\u0944');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                        case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                            dst.put('\u093d');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                        case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                                dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                                mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                            dst.put(ZWJ_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                                dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                                mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                            dst.put(NUKTA_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                    case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                        if(contextChar == HALANT_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                            dst.put(ZWNJ_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                        dst.put(HALANT_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                    case INVALID_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                            if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                        dst.put(currentChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                    }//end switch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                src.position(mark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        protected CoderResult decodeLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                                         CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            if (src.hasArray() && dst.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                return decodeArrayLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                return decodeBufferLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    private static class Encoder extends CharsetEncoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        private static final byte NO_CHAR = (byte)255;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        //private static CharToByteISCII91 c2b = new CharToByteISCII91();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        //private static final byte[] directMapTable = c2b.getISCIIEncoderMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        private final Surrogate.Parser sgp = new Surrogate.Parser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        private Encoder(Charset cs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
            super(cs, 2.0f, 2.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        public boolean canEncode(char ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            //check for Devanagari range,ZWJ,ZWNJ and ASCII range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            return ((ch >= '\u0900' && ch <= '\u097f' &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                     encoderMappingTable[2*(ch-'\u0900')] != NO_CHAR) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                    (ch == '\u200d') ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                    (ch == '\u200c') ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                    (ch <= '\u007f'));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        private CoderResult encodeArrayLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                                             ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            char[] sa = src.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            int sp = src.arrayOffset() + src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            int sl = src.arrayOffset() + src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            assert (sp <= sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            sp = (sp <= sl ? sp : sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            byte[] da = dst.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            int dp = dst.arrayOffset() + dst.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            int dl = dst.arrayOffset() + dst.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            assert (dp <= dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            dp = (dp <= dl ? dp : dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            int outputSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                char inputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                while (sp < sl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    int index = Integer.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                    inputChar = sa[sp];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                    if (inputChar >= 0x0000 && inputChar <= 0x007f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                        da[dp++] = (byte) inputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                    // if inputChar == ZWJ replace it with halant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                    // if inputChar == ZWNJ replace it with Nukta
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                    if (inputChar == 0x200c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                        inputChar = HALANT_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                    else if (inputChar == 0x200d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                        inputChar = NUKTA_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                    if (inputChar >= 0x0900 && inputChar <= 0x097f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                        index = ((int)(inputChar) - 0x0900)*2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
3714
6a4eb8f53f91 6860431: Character.isSurrogate(char ch)
martin
parents: 2
diff changeset
   888
                    if (Character.isSurrogate(inputChar)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                        if (sgp.parse(inputChar, sa, sp, sl) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                            return sgp.error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                        return sgp.unmappableResult();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                    if (index == Integer.MIN_VALUE ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                        encoderMappingTable[index] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                        if(encoderMappingTable[index + 1] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                            if(dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                            da[dp++] = encoderMappingTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                            if(dl - dp < 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                            da[dp++] = encoderMappingTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                            da[dp++] = encoderMappingTable[index + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                src.position(sp - src.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                dst.position(dp - dst.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        private CoderResult encodeBufferLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                                             ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            int mark = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                char inputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                while (src.hasRemaining()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                    int index = Integer.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    inputChar = src.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                    if (inputChar >= 0x0000 && inputChar <= 0x007f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                        dst.put((byte) inputChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                        mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                    // if inputChar == ZWJ replace it with halant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                    // if inputChar == ZWNJ replace it with Nukta
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                    if (inputChar == 0x200c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                        inputChar = HALANT_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                    else if (inputChar == 0x200d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                        inputChar = NUKTA_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                    if (inputChar >= 0x0900 && inputChar <= 0x097f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                        index = ((int)(inputChar) - 0x0900)*2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
3714
6a4eb8f53f91 6860431: Character.isSurrogate(char ch)
martin
parents: 2
diff changeset
   951
                    if (Character.isSurrogate(inputChar)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                        if (sgp.parse(inputChar, src) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                            return sgp.error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                        return sgp.unmappableResult();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                    if (index == Integer.MIN_VALUE ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                        encoderMappingTable[index] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                        if(encoderMappingTable[index + 1] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                            if(dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                            dst.put(encoderMappingTable[index]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                            if(dst.remaining() < 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                            dst.put(encoderMappingTable[index]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                            dst.put(encoderMappingTable[index + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                    mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                src.position(mark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        protected CoderResult encodeLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                                         ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
            if (src.hasArray() && dst.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                return encodeArrayLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                return encodeBufferLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
}