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