src/jdk.charsets/share/classes/sun/nio/cs/ext/ISCII91.java
author jlaskey
Thu, 14 Nov 2019 12:33:47 -0400
branchjlaskey-prng
changeset 59084 b8fb85ee91e9
parent 47216 71c04702a3d5
permissions -rw-r--r--
restarting random branch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 10343
diff changeset
     2
 * Copyright (c) 2002, 2011, 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
    private static final byte[] encoderMappingTable = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    NO_CHAR,NO_CHAR, //0900 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    (byte)161,NO_CHAR, //0901 -- DEVANAGARI SIGN CANDRABINDU = anunasika
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    (byte)162,NO_CHAR, //0902 -- DEVANAGARI SIGN ANUSVARA = bindu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    (byte)163,NO_CHAR, //0903 -- DEVANAGARI SIGN VISARGA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    NO_CHAR,NO_CHAR, //0904 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    (byte)164,NO_CHAR, //0905 -- DEVANAGARI LETTER A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    (byte)165,NO_CHAR, //0906 -- DEVANAGARI LETTER AA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    (byte)166,NO_CHAR, //0907 -- DEVANAGARI LETTER I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    (byte)167,NO_CHAR, //0908 -- DEVANAGARI LETTER II
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    (byte)168,NO_CHAR, //0909 -- DEVANAGARI LETTER U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    (byte)169,NO_CHAR, //090a -- DEVANAGARI LETTER UU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    (byte)170,NO_CHAR, //090b -- DEVANAGARI LETTER VOCALIC R
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    (byte)166,(byte)233, //090c -- DEVANAGARI LETTER VOVALIC L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    (byte)174,NO_CHAR, //090d -- DEVANAGARI LETTER CANDRA E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    (byte)171,NO_CHAR, //090e -- DEVANAGARI LETTER SHORT E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    (byte)172,NO_CHAR, //090f -- DEVANAGARI LETTER E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    (byte)173,NO_CHAR, //0910 -- DEVANAGARI LETTER AI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    (byte)178,NO_CHAR, //0911 -- DEVANAGARI LETTER CANDRA O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    (byte)175,NO_CHAR, //0912 -- DEVANAGARI LETTER SHORT O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    (byte)176,NO_CHAR, //0913 -- DEVANAGARI LETTER O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    (byte)177,NO_CHAR, //0914 -- DEVANAGARI LETTER AU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    (byte)179,NO_CHAR, //0915 -- DEVANAGARI LETTER KA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    (byte)180,NO_CHAR, //0916 -- DEVANAGARI LETTER KHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    (byte)181,NO_CHAR, //0917 -- DEVANAGARI LETTER GA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    (byte)182,NO_CHAR, //0918 -- DEVANAGARI LETTER GHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    (byte)183,NO_CHAR, //0919 -- DEVANAGARI LETTER NGA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    (byte)184,NO_CHAR, //091a -- DEVANAGARI LETTER CA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    (byte)185,NO_CHAR, //091b -- DEVANAGARI LETTER CHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    (byte)186,NO_CHAR, //091c -- DEVANAGARI LETTER JA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    (byte)187,NO_CHAR, //091d -- DEVANAGARI LETTER JHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    (byte)188,NO_CHAR, //091e -- DEVANAGARI LETTER NYA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    (byte)189,NO_CHAR, //091f -- DEVANAGARI LETTER TTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    (byte)190,NO_CHAR, //0920 -- DEVANAGARI LETTER TTHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    (byte)191,NO_CHAR, //0921 -- DEVANAGARI LETTER DDA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    (byte)192,NO_CHAR, //0922 -- DEVANAGARI LETTER DDHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    (byte)193,NO_CHAR, //0923 -- DEVANAGARI LETTER NNA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    (byte)194,NO_CHAR, //0924 -- DEVANAGARI LETTER TA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    (byte)195,NO_CHAR, //0925 -- DEVANAGARI LETTER THA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    (byte)196,NO_CHAR, //0926 -- DEVANAGARI LETTER DA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    (byte)197,NO_CHAR, //0927 -- DEVANAGARI LETTER DHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    (byte)198,NO_CHAR, //0928 -- DEVANAGARI LETTER NA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    (byte)199,NO_CHAR, //0929 -- DEVANAGARI LETTER NNNA <=> 0928 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    (byte)200,NO_CHAR, //092a -- DEVANAGARI LETTER PA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    (byte)201,NO_CHAR, //092b -- DEVANAGARI LETTER PHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    (byte)202,NO_CHAR, //092c -- DEVANAGARI LETTER BA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    (byte)203,NO_CHAR, //092d -- DEVANAGARI LETTER BHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    (byte)204,NO_CHAR, //092e -- DEVANAGARI LETTER MA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    (byte)205,NO_CHAR, //092f -- DEVANAGARI LETTER YA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    (byte)207,NO_CHAR, //0930 -- DEVANAGARI LETTER RA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    (byte)208,NO_CHAR, //0931 -- DEVANAGARI LETTER RRA <=> 0930 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    (byte)209,NO_CHAR, //0932 -- DEVANAGARI LETTER LA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    (byte)210,NO_CHAR, //0933 -- DEVANAGARI LETTER LLA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    (byte)211,NO_CHAR, //0934 -- DEVANAGARI LETTER LLLA <=> 0933 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    (byte)212,NO_CHAR, //0935 -- DEVANAGARI LETTER VA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    (byte)213,NO_CHAR, //0936 -- DEVANAGARI LETTER SHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    (byte)214,NO_CHAR, //0937 -- DEVANAGARI LETTER SSA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    (byte)215,NO_CHAR, //0938 -- DEVANAGARI LETTER SA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    (byte)216,NO_CHAR, //0939 -- DEVANAGARI LETTER HA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    NO_CHAR,NO_CHAR, //093a <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    NO_CHAR,NO_CHAR, //093b <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    (byte)233,NO_CHAR, //093c -- DEVANAGARI SIGN NUKTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    (byte)234,(byte)233, //093d -- DEVANAGARI SIGN AVAGRAHA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    (byte)218,NO_CHAR, //093e -- DEVANAGARI VOWEL SIGN AA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    (byte)219,NO_CHAR, //093f -- DEVANAGARI VOWEL SIGN I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    (byte)220,NO_CHAR, //0940 -- DEVANAGARI VOWEL SIGN II
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    (byte)221,NO_CHAR, //0941 -- DEVANAGARI VOWEL SIGN U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    (byte)222,NO_CHAR, //0942 -- DEVANAGARI VOWEL SIGN UU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    (byte)223,NO_CHAR, //0943 -- DEVANAGARI VOWEL SIGN VOCALIC R
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    (byte)223,(byte)233, //0944 -- DEVANAGARI VOWEL SIGN VOCALIC RR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    (byte)227,NO_CHAR, //0945 -- DEVANAGARI VOWEL SIGN CANDRA E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    (byte)224,NO_CHAR, //0946 -- DEVANAGARI VOWEL SIGN SHORT E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    (byte)225,NO_CHAR, //0947 -- DEVANAGARI VOWEL SIGN E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    (byte)226,NO_CHAR, //0948 -- DEVANAGARI VOWEL SIGN AI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    (byte)231,NO_CHAR, //0949 -- DEVANAGARI VOWEL SIGN CANDRA O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    (byte)228,NO_CHAR, //094a -- DEVANAGARI VOWEL SIGN SHORT O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    (byte)229,NO_CHAR, //094b -- DEVANAGARI VOWEL SIGN O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    (byte)230,NO_CHAR, //094c -- DEVANAGARI VOWEL SIGN AU
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    (byte)232,NO_CHAR, //094d -- DEVANAGARI SIGN VIRAMA ( halant )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    NO_CHAR,NO_CHAR, //094e <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    NO_CHAR,NO_CHAR, //094f <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    (byte)161,(byte)233, //0950 -- DEVANAGARI OM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    (byte)240,(byte)181, //0951 -- DEVANAGARI STRESS SIGN UDATTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    (byte)240,(byte)184, //0952 -- DEVANAGARI STRESS SIGN ANUDATTA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    (byte)254,NO_CHAR, //0953 -- DEVANAGARI GRAVE ACCENT || MISSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    (byte)254,NO_CHAR, //0954 -- DEVANAGARI ACUTE ACCENT || MISSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    NO_CHAR,NO_CHAR, //0955 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    NO_CHAR,NO_CHAR, //0956 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    NO_CHAR,NO_CHAR, //0957 <reserved>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    (byte)179,(byte)233, //0958 -- DEVANAGARI LETTER QA <=> 0915 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    (byte)180,(byte)233, //0959 -- DEVANAGARI LETTER KHHA <=> 0916 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    (byte)181,(byte)233, //095a -- DEVANAGARI LETTER GHHA <=> 0917 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    (byte)186,(byte)233, //095b -- DEVANAGARI LETTER ZA <=> 091C + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    (byte)191,(byte)233, //095c -- DEVANAGARI LETTER DDDHA <=> 0921 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    (byte)192,(byte)233, //095d -- DEVANAGARI LETTER RHA <=> 0922 + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    (byte)201,(byte)233, //095e -- DEVANAGARI LETTER FA <=> 092B + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    (byte)206,NO_CHAR, //095f -- DEVANAGARI LETTER YYA <=> 092F + 093C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    (byte)170,(byte)233, //0960 -- DEVANAGARI LETTER VOCALIC RR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    (byte)167,(byte)233, //0961 -- DEVANAGARI LETTER VOCALIC LL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    (byte)219,(byte)233, //0962 -- DEVANAGARI VOWEL SIGN VOCALIC L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    (byte)220,(byte)233, //0963 -- DEVANAGARI VOWEL SIGN VOCALIC LL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    (byte)234,NO_CHAR, //0964 -- DEVANAGARI DANDA ( phrase separator )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    (byte)234,(byte)234, //0965 -- DEVANAGARI DOUBLE DANDA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    (byte)241,NO_CHAR, //0966 -- DEVANAGARI DIGIT ZERO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    (byte)242,NO_CHAR, //0967 -- DEVANAGARI DIGIT ONE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    (byte)243,NO_CHAR, //0968 -- DEVANAGARI DIGIT TWO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    (byte)244,NO_CHAR, //0969 -- DEVANAGARI DIGIT THREE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    (byte)245,NO_CHAR, //096a -- DEVANAGARI DIGIT FOUR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    (byte)246,NO_CHAR, //096b -- DEVANAGARI DIGIT FIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    (byte)247,NO_CHAR, //096c -- DEVANAGARI DIGIT SIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    (byte)248,NO_CHAR, //096d -- DEVANAGARI DIGIT SEVEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    (byte)249,NO_CHAR, //096e -- DEVANAGARI DIGIT EIGHT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    (byte)250,NO_CHAR, //096f -- DEVANAGARI DIGIT NINE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    (byte)240,(byte)191,  //0970 -- DEVANAGARI ABBREVIATION SIGN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    NO_CHAR,NO_CHAR, //0971 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    NO_CHAR,NO_CHAR, //0972 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    NO_CHAR,NO_CHAR, //0973 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    NO_CHAR,NO_CHAR, //0974 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    NO_CHAR,NO_CHAR, //0975 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    NO_CHAR,NO_CHAR, //0976 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    NO_CHAR,NO_CHAR, //0977 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    NO_CHAR,NO_CHAR, //0978 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    NO_CHAR,NO_CHAR, //0979 -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    NO_CHAR,NO_CHAR, //097a -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    NO_CHAR,NO_CHAR, //097b -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    NO_CHAR,NO_CHAR, //097c -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    NO_CHAR,NO_CHAR, //097d -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    NO_CHAR,NO_CHAR, //097e -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    NO_CHAR,NO_CHAR  //097f -- reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }; //end of table definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    private static class Decoder extends CharsetDecoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        private static final char ZWNJ_CHAR = '\u200c';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        private static final char ZWJ_CHAR = '\u200d';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        private static final char INVALID_CHAR = '\uffff';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        private char contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        private boolean needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        private Decoder(Charset cs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            super(cs, 1.0f, 1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        protected CoderResult implFlush(CharBuffer out) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                if (out.remaining() < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                    return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    out.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        /*Rules:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
         * 1)ATR,EXT,following character to be replaced with '\ufffd'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
         * 2)Halant + Halant => '\u094d' (Virama) + '\u200c'(ZWNJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
         * 3)Halant + Nukta => '\u094d' (Virama) + '\u200d'(ZWJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        private CoderResult decodeArrayLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                             CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            byte[] sa = src.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            int sp = src.arrayOffset() + src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            int sl = src.arrayOffset() + src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            assert (sp <= sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            sp = (sp <= sl ? sp : sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            char[] da = dst.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            int dp = dst.arrayOffset() + dst.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            int dl = dst.arrayOffset() + dst.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            assert (dp <= dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            dp = (dp <= dl ? dp : dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                while (sp < sl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                    int index = sa[sp];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                    index = ( index < 0 )? ( index + 255 ):index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                    char currentChar = directMapTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    // if the contextChar is either ATR || EXT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                    // set the output to '\ufffd'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                    if(contextChar == '\ufffd') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                        da[dp++] = '\ufffd';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                        contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                        needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                    switch(currentChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                    case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                    case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                    case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                    case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                    case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                    case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                    case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                    case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                            if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                        contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                        needFlushing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                    case NUKTA_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                        switch(contextChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                        case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                            da[dp++] = '\u0950';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                        case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                            da[dp++] = '\u090c';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                        case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                            da[dp++] = '\u0961';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                        case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                            da[dp++] = '\u0960';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                            da[dp++] = '\u0962';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                        case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                            da[dp++] = '\u0963';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                        case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                            da[dp++] = '\u0944';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                        case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                            da[dp++] = '\u093d';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                        case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                                da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                                sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                            da[dp++] = ZWJ_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                                da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                                sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                            da[dp++] = NUKTA_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                    case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                        if(contextChar == HALANT_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                            da[dp++] = ZWNJ_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                        da[dp++] = HALANT_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    case INVALID_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                            if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                            da[dp++] = contextChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                            sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                        da[dp++] = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                    }//end switch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
           } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                src.position(sp - src.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                dst.position(dp - dst.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        private CoderResult decodeBufferLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                                             CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            int mark = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                while (src.hasRemaining()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                    int index = src.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                    index = ( index < 0 )? ( index + 255 ):index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                    char currentChar = directMapTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                    // if the contextChar is either ATR || EXT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                    // set the output to '\ufffd'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                    if(contextChar == '\ufffd') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                        dst.put('\ufffd');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                        contextChar = INVALID_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                        needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                        mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                    switch(currentChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                    case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                    case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                    case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                    case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                    case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                    case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                    case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                    case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                            if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                        contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                        needFlushing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                        mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                    case NUKTA_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                        switch(contextChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                        case '\u0901':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                            dst.put('\u0950');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                        case '\u0907':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                            dst.put('\u090c');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                        case '\u0908':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                            dst.put('\u0961');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                        case '\u090b':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                            dst.put('\u0960');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                        case '\u093f':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                            dst.put('\u0962');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                        case '\u0940':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                            dst.put('\u0963');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                        case '\u0943':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                            dst.put('\u0944');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                        case '\u0964':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                            dst.put('\u093d');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                        case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                                dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                                mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                            dst.put(ZWJ_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                            if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                                dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                                mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                            dst.put(NUKTA_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    case HALANT_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                        if(contextChar == HALANT_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                            dst.put(ZWNJ_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                        dst.put(HALANT_CHAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                    case INVALID_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                            if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                        if(needFlushing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                            dst.put(contextChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                            contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                            mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                        dst.put(currentChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                    }//end switch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                contextChar = currentChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                needFlushing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                src.position(mark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        protected CoderResult decodeLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                                         CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            if (src.hasArray() && dst.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                return decodeArrayLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                return decodeBufferLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    private static class Encoder extends CharsetEncoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        private static final byte NO_CHAR = (byte)255;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        //private static CharToByteISCII91 c2b = new CharToByteISCII91();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        //private static final byte[] directMapTable = c2b.getISCIIEncoderMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        private final Surrogate.Parser sgp = new Surrogate.Parser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        private Encoder(Charset cs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            super(cs, 2.0f, 2.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        public boolean canEncode(char ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            //check for Devanagari range,ZWJ,ZWNJ and ASCII range.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            return ((ch >= '\u0900' && ch <= '\u097f' &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                     encoderMappingTable[2*(ch-'\u0900')] != NO_CHAR) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                    (ch == '\u200d') ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                    (ch == '\u200c') ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                    (ch <= '\u007f'));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        private CoderResult encodeArrayLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                                             ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            char[] sa = src.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            int sp = src.arrayOffset() + src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            int sl = src.arrayOffset() + src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            assert (sp <= sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            sp = (sp <= sl ? sp : sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            byte[] da = dst.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            int dp = dst.arrayOffset() + dst.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            int dl = dst.arrayOffset() + dst.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            assert (dp <= dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
            dp = (dp <= dl ? dp : dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            int outputSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                char inputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                while (sp < sl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                    int index = Integer.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                    inputChar = sa[sp];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                    if (inputChar >= 0x0000 && inputChar <= 0x007f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                        if (dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                        da[dp++] = (byte) inputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                    // if inputChar == ZWJ replace it with halant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                    // if inputChar == ZWNJ replace it with Nukta
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                    if (inputChar == 0x200c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                        inputChar = HALANT_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                    else if (inputChar == 0x200d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                        inputChar = NUKTA_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                    if (inputChar >= 0x0900 && inputChar <= 0x097f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                        index = ((int)(inputChar) - 0x0900)*2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
3714
6a4eb8f53f91 6860431: Character.isSurrogate(char ch)
martin
parents: 2
diff changeset
   862
                    if (Character.isSurrogate(inputChar)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                        if (sgp.parse(inputChar, sa, sp, sl) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                            return sgp.error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                        return sgp.unmappableResult();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                    if (index == Integer.MIN_VALUE ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                        encoderMappingTable[index] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                        if(encoderMappingTable[index + 1] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                            if(dl - dp < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                            da[dp++] = encoderMappingTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                            if(dl - dp < 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                            da[dp++] = encoderMappingTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                            da[dp++] = encoderMappingTable[index + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                src.position(sp - src.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                dst.position(dp - dst.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        private CoderResult encodeBufferLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                                             ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            int mark = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                char inputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                while (src.hasRemaining()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                    int index = Integer.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                    inputChar = src.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                    if (inputChar >= 0x0000 && inputChar <= 0x007f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                        if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                            return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                        dst.put((byte) inputChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                        mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                    // if inputChar == ZWJ replace it with halant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                    // if inputChar == ZWNJ replace it with Nukta
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                    if (inputChar == 0x200c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                        inputChar = HALANT_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                    else if (inputChar == 0x200d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                        inputChar = NUKTA_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                    if (inputChar >= 0x0900 && inputChar <= 0x097f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                        index = ((int)(inputChar) - 0x0900)*2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
3714
6a4eb8f53f91 6860431: Character.isSurrogate(char ch)
martin
parents: 2
diff changeset
   925
                    if (Character.isSurrogate(inputChar)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                        if (sgp.parse(inputChar, src) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                            return sgp.error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                        return sgp.unmappableResult();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                    if (index == Integer.MIN_VALUE ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                        encoderMappingTable[index] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                        return CoderResult.unmappableForLength(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                        if(encoderMappingTable[index + 1] == NO_CHAR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                            if(dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                            dst.put(encoderMappingTable[index]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                            if(dst.remaining() < 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                                return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                            dst.put(encoderMappingTable[index]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                            dst.put(encoderMappingTable[index + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                    mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                src.position(mark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        protected CoderResult encodeLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                                         ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            if (src.hasArray() && dst.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                return encodeArrayLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                return encodeBufferLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
}