0N/A/*
2362N/A * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A */
0N/A
0N/A
0N/Apackage sun.nio.cs.ext;
0N/A
0N/Aimport java.nio.charset.Charset;
0N/Aimport java.nio.CharBuffer;
0N/Aimport java.nio.ByteBuffer;
0N/Aimport java.nio.charset.CharsetDecoder;
0N/Aimport java.nio.charset.CharsetEncoder;
0N/Aimport java.nio.charset.CoderResult;
0N/Aimport sun.nio.cs.Surrogate;
0N/Aimport sun.nio.cs.HistoricallyNamedCharset;
0N/A
0N/Apublic class ISCII91 extends Charset implements HistoricallyNamedCharset
0N/A{
0N/A private static final char NUKTA_CHAR = '\u093c';
0N/A private static final char HALANT_CHAR = '\u094d';
0N/A private static final byte NO_CHAR = (byte)255;
0N/A
0N/A public ISCII91() {
0N/A super("x-ISCII91", ExtendedCharsets.aliasesFor("x-ISCII91"));
0N/A }
0N/A
0N/A public String historicalName() {
0N/A return "ISCII91";
0N/A }
0N/A
0N/A public boolean contains(Charset cs) {
0N/A return ((cs.name().equals("US-ASCII"))
0N/A || (cs instanceof ISCII91));
0N/A }
0N/A
0N/A public CharsetDecoder newDecoder() {
0N/A return new Decoder(this);
0N/A }
0N/A
0N/A public CharsetEncoder newEncoder() {
0N/A return new Encoder(this);
0N/A }
0N/A
0N/A private static final char[] directMapTable = {
0N/A '\u0000', // ascii character
0N/A '\u0001', // ascii character
0N/A '\u0002', // ascii character
0N/A '\u0003', // ascii character
0N/A '\u0004', // ascii character
0N/A '\u0005', // ascii character
0N/A '\u0006', // ascii character
0N/A '\u0007', // ascii character
0N/A '\u0008', // ascii character
0N/A '\u0009', // ascii character
0N/A '\012', // ascii character
0N/A '\u000b', // ascii character
0N/A '\u000c', // ascii character
0N/A '\015', // ascii character
0N/A '\u000e', // ascii character
0N/A '\u000f', // ascii character
0N/A '\u0010', // ascii character
0N/A '\u0011', // ascii character
0N/A '\u0012', // ascii character
0N/A '\u0013', // ascii character
0N/A '\u0014', // ascii character
0N/A '\u0015', // ascii character
0N/A '\u0016', // ascii character
0N/A '\u0017', // ascii character
0N/A '\u0018', // ascii character
0N/A '\u0019', // ascii character
0N/A '\u001a', // ascii character
0N/A '\u001b', // ascii character
0N/A '\u001c', // ascii character
0N/A '\u001d', // ascii character
0N/A '\u001e', // ascii character
0N/A '\u001f', // ascii character
0N/A '\u0020', // ascii character
0N/A '\u0021', // ascii character
0N/A '\u0022', // ascii character
0N/A '\u0023', // ascii character
0N/A '\u0024', // ascii character
0N/A '\u0025', // ascii character
0N/A '\u0026', // ascii character
0N/A (char)0x0027, // '\u0027' control -- ascii character
0N/A '\u0028', // ascii character
0N/A '\u0029', // ascii character
0N/A '\u002a', // ascii character
0N/A '\u002b', // ascii character
0N/A '\u002c', // ascii character
0N/A '\u002d', // ascii character
0N/A '\u002e', // ascii character
0N/A '\u002f', // ascii character
0N/A '\u0030', // ascii character
0N/A '\u0031', // ascii character
0N/A '\u0032', // ascii character
0N/A '\u0033', // ascii character
0N/A '\u0034', // ascii character
0N/A '\u0035', // ascii character
0N/A '\u0036', // ascii character
0N/A '\u0037', // ascii character
0N/A '\u0038', // ascii character
0N/A '\u0039', // ascii character
0N/A '\u003a', // ascii character
0N/A '\u003b', // ascii character
0N/A '\u003c', // ascii character
0N/A '\u003d', // ascii character
0N/A '\u003e', // ascii character
0N/A '\u003f', // ascii character
0N/A '\u0040', // ascii character
0N/A '\u0041', // ascii character
0N/A '\u0042', // ascii character
0N/A '\u0043', // ascii character
0N/A '\u0044', // ascii character
0N/A '\u0045', // ascii character
0N/A '\u0046', // ascii character
0N/A '\u0047', // ascii character
0N/A '\u0048', // ascii character
0N/A '\u0049', // ascii character
0N/A '\u004a', // ascii character
0N/A '\u004b', // ascii character
0N/A '\u004c', // ascii character
0N/A '\u004d', // ascii character
0N/A '\u004e', // ascii character
0N/A '\u004f', // ascii character
0N/A '\u0050', // ascii character
0N/A '\u0051', // ascii character
0N/A '\u0052', // ascii character
0N/A '\u0053', // ascii character
0N/A '\u0054', // ascii character
0N/A '\u0055', // ascii character
0N/A '\u0056', // ascii character
0N/A '\u0057', // ascii character
0N/A '\u0058', // ascii character
0N/A '\u0059', // ascii character
0N/A '\u005a', // ascii character
0N/A '\u005b', // ascii character
0N/A '\\',// '\u005c' -- ascii character
0N/A '\u005d', // ascii character
0N/A '\u005e', // ascii character
0N/A '\u005f', // ascii character
0N/A '\u0060', // ascii character
0N/A '\u0061', // ascii character
0N/A '\u0062', // ascii character
0N/A '\u0063', // ascii character
0N/A '\u0064', // ascii character
0N/A '\u0065', // ascii character
0N/A '\u0066', // ascii character
0N/A '\u0067', // ascii character
0N/A '\u0068', // ascii character
0N/A '\u0069', // ascii character
0N/A '\u006a', // ascii character
0N/A '\u006b', // ascii character
0N/A '\u006c', // ascii character
0N/A '\u006d', // ascii character
0N/A '\u006e', // ascii character
0N/A '\u006f', // ascii character
0N/A '\u0070', // ascii character
0N/A '\u0071', // ascii character
0N/A '\u0072', // ascii character
0N/A '\u0073', // ascii character
0N/A '\u0074', // ascii character
0N/A '\u0075', // ascii character
0N/A '\u0076', // ascii character
0N/A '\u0077', // ascii character
0N/A '\u0078', // ascii character
0N/A '\u0079', // ascii character
0N/A '\u007a', // ascii character
0N/A '\u007b', // ascii character
0N/A '\u007c', // ascii character
0N/A '\u007d', // ascii character
0N/A '\u007e', // ascii character
0N/A '\u007f', // ascii character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\uffff', // unknown character
0N/A '\u0901', // a1 -- Vowel-modifier CHANDRABINDU
0N/A '\u0902', // a2 -- Vowel-modifier ANUSWAR
0N/A '\u0903', // a3 -- Vowel-modifier VISARG
0N/A
0N/A '\u0905', // a4 -- Vowel A
0N/A '\u0906', // a5 -- Vowel AA
0N/A '\u0907', // a6 -- Vowel I
0N/A '\u0908', // a7 -- Vowel II
0N/A '\u0909', // a8 -- Vowel U
0N/A '\u090a', // a9 -- Vowel UU
0N/A '\u090b', // aa -- Vowel RI
0N/A '\u090e', // ab -- Vowel E ( Southern Scripts )
0N/A '\u090f', // ac -- Vowel EY
0N/A '\u0910', // ad -- Vowel AI
0N/A '\u090d', // ae -- Vowel AYE ( Devanagari Script )
0N/A '\u0912', // af -- Vowel O ( Southern Scripts )
0N/A '\u0913', // b0 -- Vowel OW
0N/A '\u0914', // b1 -- Vowel AU
0N/A '\u0911', // b2 -- Vowel AWE ( Devanagari Script )
0N/A '\u0915', // b3 -- Consonant KA
0N/A '\u0916', // b4 -- Consonant KHA
0N/A '\u0917', // b5 -- Consonant GA
0N/A '\u0918', // b6 -- Consonant GHA
0N/A '\u0919', // b7 -- Consonant NGA
0N/A '\u091a', // b8 -- Consonant CHA
0N/A '\u091b', // b9 -- Consonant CHHA
0N/A '\u091c', // ba -- Consonant JA
0N/A '\u091d', // bb -- Consonant JHA
0N/A '\u091e', // bc -- Consonant JNA
0N/A '\u091f', // bd -- Consonant Hard TA
0N/A '\u0920', // be -- Consonant Hard THA
0N/A '\u0921', // bf -- Consonant Hard DA
0N/A '\u0922', // c0 -- Consonant Hard DHA
0N/A '\u0923', // c1 -- Consonant Hard NA
0N/A '\u0924', // c2 -- Consonant Soft TA
0N/A '\u0925', // c3 -- Consonant Soft THA
0N/A '\u0926', // c4 -- Consonant Soft DA
0N/A '\u0927', // c5 -- Consonant Soft DHA
0N/A '\u0928', // c6 -- Consonant Soft NA
0N/A '\u0929', // c7 -- Consonant NA ( Tamil )
0N/A '\u092a', // c8 -- Consonant PA
0N/A '\u092b', // c9 -- Consonant PHA
0N/A '\u092c', // ca -- Consonant BA
0N/A '\u092d', // cb -- Consonant BHA
0N/A '\u092e', // cc -- Consonant MA
0N/A '\u092f', // cd -- Consonant YA
0N/A '\u095f', // ce -- Consonant JYA ( Bengali, Assamese & Oriya )
0N/A '\u0930', // cf -- Consonant RA
0N/A '\u0931', // d0 -- Consonant Hard RA ( Southern Scripts )
0N/A '\u0932', // d1 -- Consonant LA
0N/A '\u0933', // d2 -- Consonant Hard LA
0N/A '\u0934', // d3 -- Consonant ZHA ( Tamil & Malayalam )
0N/A '\u0935', // d4 -- Consonant VA
0N/A '\u0936', // d5 -- Consonant SHA
0N/A '\u0937', // d6 -- Consonant Hard SHA
0N/A '\u0938', // d7 -- Consonant SA
0N/A '\u0939', // d8 -- Consonant HA
0N/A
0N/A '\u200d', // d9 -- Consonant INVISIBLE
0N/A '\u093e', // da -- Vowel Sign AA
0N/A
0N/A '\u093f', // db -- Vowel Sign I
0N/A '\u0940', // dc -- Vowel Sign II
0N/A '\u0941', // dd -- Vowel Sign U
0N/A '\u0942', // de -- Vowel Sign UU
0N/A '\u0943', // df -- Vowel Sign RI
0N/A '\u0946', // e0 -- Vowel Sign E ( Southern Scripts )
0N/A '\u0947', // e1 -- Vowel Sign EY
0N/A '\u0948', // e2 -- Vowel Sign AI
0N/A '\u0945', // e3 -- Vowel Sign AYE ( Devanagari Script )
0N/A '\u094a', // e4 -- Vowel Sign O ( Southern Scripts )
0N/A '\u094b', // e5 -- Vowel Sign OW
0N/A '\u094c', // e6 -- Vowel Sign AU
0N/A '\u0949', // e7 -- Vowel Sign AWE ( Devanagari Script )
0N/A
0N/A '\u094d', // e8 -- Vowel Omission Sign ( Halant )
0N/A '\u093c', // e9 -- Diacritic Sign ( Nukta )
0N/A '\u0964', // ea -- Full Stop ( Viram, Northern Scripts )
0N/A
0N/A '\uffff', // eb -- This position shall not be used
0N/A '\uffff', // ec -- This position shall not be used
0N/A '\uffff', // ed -- This position shall not be used
0N/A '\uffff', // ee -- This position shall not be used
0N/A
0N/A '\ufffd', // ef -- Attribute Code ( ATR )
0N/A '\ufffd', // f0 -- Extension Code ( EXT )
0N/A
0N/A '\u0966', // f1 -- Digit 0
0N/A '\u0967', // f2 -- Digit 1
0N/A '\u0968', // f3 -- Digit 2
0N/A '\u0969', // f4 -- Digit 3
0N/A '\u096a', // f5 -- Digit 4
0N/A '\u096b', // f6 -- Digit 5
0N/A '\u096c', // f7 -- Digit 6
0N/A '\u096d', // f8 -- Digit 7
0N/A '\u096e', // f9 -- Digit 8
0N/A '\u096f', // fa -- Digit 9
0N/A
0N/A '\uffff', // fb -- This position shall not be used
0N/A '\uffff', // fc -- This position shall not be used
0N/A '\uffff', // fd -- This position shall not be used
0N/A '\uffff', // fe -- This position shall not be used
0N/A '\uffff' // ff -- This position shall not be used
0N/A }; //end of table definition
0N/A
0N/A /**
0N/A * This accessor is temporarily supplied while sun.io
0N/A * converters co-exist with the sun.nio.cs.{ext} charset coders
0N/A * These facilitate sharing of conversion tables between the
0N/A * two co-existing implementations. When sun.io converters
0N/A * are made extinct these will be unnecessary and should be removed
0N/A */
0N/A
0N/A public static char[] getDirectMapTable() {
0N/A return directMapTable;
0N/A }
0N/A
0N/A private static final byte[] encoderMappingTable = {
0N/A NO_CHAR,NO_CHAR, //0900 <reserved>
0N/A (byte)161,NO_CHAR, //0901 -- DEVANAGARI SIGN CANDRABINDU = anunasika
0N/A (byte)162,NO_CHAR, //0902 -- DEVANAGARI SIGN ANUSVARA = bindu
0N/A (byte)163,NO_CHAR, //0903 -- DEVANAGARI SIGN VISARGA
0N/A NO_CHAR,NO_CHAR, //0904 <reserved>
0N/A (byte)164,NO_CHAR, //0905 -- DEVANAGARI LETTER A
0N/A (byte)165,NO_CHAR, //0906 -- DEVANAGARI LETTER AA
0N/A (byte)166,NO_CHAR, //0907 -- DEVANAGARI LETTER I
0N/A (byte)167,NO_CHAR, //0908 -- DEVANAGARI LETTER II
0N/A (byte)168,NO_CHAR, //0909 -- DEVANAGARI LETTER U
0N/A (byte)169,NO_CHAR, //090a -- DEVANAGARI LETTER UU
0N/A (byte)170,NO_CHAR, //090b -- DEVANAGARI LETTER VOCALIC R
0N/A (byte)166,(byte)233, //090c -- DEVANAGARI LETTER VOVALIC L
0N/A (byte)174,NO_CHAR, //090d -- DEVANAGARI LETTER CANDRA E
0N/A (byte)171,NO_CHAR, //090e -- DEVANAGARI LETTER SHORT E
0N/A (byte)172,NO_CHAR, //090f -- DEVANAGARI LETTER E
0N/A (byte)173,NO_CHAR, //0910 -- DEVANAGARI LETTER AI
0N/A (byte)178,NO_CHAR, //0911 -- DEVANAGARI LETTER CANDRA O
0N/A (byte)175,NO_CHAR, //0912 -- DEVANAGARI LETTER SHORT O
0N/A (byte)176,NO_CHAR, //0913 -- DEVANAGARI LETTER O
0N/A (byte)177,NO_CHAR, //0914 -- DEVANAGARI LETTER AU
0N/A (byte)179,NO_CHAR, //0915 -- DEVANAGARI LETTER KA
0N/A (byte)180,NO_CHAR, //0916 -- DEVANAGARI LETTER KHA
0N/A (byte)181,NO_CHAR, //0917 -- DEVANAGARI LETTER GA
0N/A (byte)182,NO_CHAR, //0918 -- DEVANAGARI LETTER GHA
0N/A (byte)183,NO_CHAR, //0919 -- DEVANAGARI LETTER NGA
0N/A (byte)184,NO_CHAR, //091a -- DEVANAGARI LETTER CA
0N/A (byte)185,NO_CHAR, //091b -- DEVANAGARI LETTER CHA
0N/A (byte)186,NO_CHAR, //091c -- DEVANAGARI LETTER JA
0N/A (byte)187,NO_CHAR, //091d -- DEVANAGARI LETTER JHA
0N/A (byte)188,NO_CHAR, //091e -- DEVANAGARI LETTER NYA
0N/A (byte)189,NO_CHAR, //091f -- DEVANAGARI LETTER TTA
0N/A (byte)190,NO_CHAR, //0920 -- DEVANAGARI LETTER TTHA
0N/A (byte)191,NO_CHAR, //0921 -- DEVANAGARI LETTER DDA
0N/A (byte)192,NO_CHAR, //0922 -- DEVANAGARI LETTER DDHA
0N/A (byte)193,NO_CHAR, //0923 -- DEVANAGARI LETTER NNA
0N/A (byte)194,NO_CHAR, //0924 -- DEVANAGARI LETTER TA
0N/A (byte)195,NO_CHAR, //0925 -- DEVANAGARI LETTER THA
0N/A (byte)196,NO_CHAR, //0926 -- DEVANAGARI LETTER DA
0N/A (byte)197,NO_CHAR, //0927 -- DEVANAGARI LETTER DHA
0N/A (byte)198,NO_CHAR, //0928 -- DEVANAGARI LETTER NA
0N/A (byte)199,NO_CHAR, //0929 -- DEVANAGARI LETTER NNNA <=> 0928 + 093C
0N/A (byte)200,NO_CHAR, //092a -- DEVANAGARI LETTER PA
0N/A (byte)201,NO_CHAR, //092b -- DEVANAGARI LETTER PHA
0N/A (byte)202,NO_CHAR, //092c -- DEVANAGARI LETTER BA
0N/A (byte)203,NO_CHAR, //092d -- DEVANAGARI LETTER BHA
0N/A (byte)204,NO_CHAR, //092e -- DEVANAGARI LETTER MA
0N/A (byte)205,NO_CHAR, //092f -- DEVANAGARI LETTER YA
0N/A (byte)207,NO_CHAR, //0930 -- DEVANAGARI LETTER RA
0N/A (byte)208,NO_CHAR, //0931 -- DEVANAGARI LETTER RRA <=> 0930 + 093C
0N/A (byte)209,NO_CHAR, //0932 -- DEVANAGARI LETTER LA
0N/A (byte)210,NO_CHAR, //0933 -- DEVANAGARI LETTER LLA
0N/A (byte)211,NO_CHAR, //0934 -- DEVANAGARI LETTER LLLA <=> 0933 + 093C
0N/A (byte)212,NO_CHAR, //0935 -- DEVANAGARI LETTER VA
0N/A (byte)213,NO_CHAR, //0936 -- DEVANAGARI LETTER SHA
0N/A (byte)214,NO_CHAR, //0937 -- DEVANAGARI LETTER SSA
0N/A (byte)215,NO_CHAR, //0938 -- DEVANAGARI LETTER SA
0N/A (byte)216,NO_CHAR, //0939 -- DEVANAGARI LETTER HA
0N/A NO_CHAR,NO_CHAR, //093a <reserved>
0N/A NO_CHAR,NO_CHAR, //093b <reserved>
0N/A (byte)233,NO_CHAR, //093c -- DEVANAGARI SIGN NUKTA
0N/A (byte)234,(byte)233, //093d -- DEVANAGARI SIGN AVAGRAHA
0N/A (byte)218,NO_CHAR, //093e -- DEVANAGARI VOWEL SIGN AA
0N/A (byte)219,NO_CHAR, //093f -- DEVANAGARI VOWEL SIGN I
0N/A (byte)220,NO_CHAR, //0940 -- DEVANAGARI VOWEL SIGN II
0N/A (byte)221,NO_CHAR, //0941 -- DEVANAGARI VOWEL SIGN U
0N/A (byte)222,NO_CHAR, //0942 -- DEVANAGARI VOWEL SIGN UU
0N/A (byte)223,NO_CHAR, //0943 -- DEVANAGARI VOWEL SIGN VOCALIC R
0N/A (byte)223,(byte)233, //0944 -- DEVANAGARI VOWEL SIGN VOCALIC RR
0N/A (byte)227,NO_CHAR, //0945 -- DEVANAGARI VOWEL SIGN CANDRA E
0N/A (byte)224,NO_CHAR, //0946 -- DEVANAGARI VOWEL SIGN SHORT E
0N/A (byte)225,NO_CHAR, //0947 -- DEVANAGARI VOWEL SIGN E
0N/A (byte)226,NO_CHAR, //0948 -- DEVANAGARI VOWEL SIGN AI
0N/A (byte)231,NO_CHAR, //0949 -- DEVANAGARI VOWEL SIGN CANDRA O
0N/A (byte)228,NO_CHAR, //094a -- DEVANAGARI VOWEL SIGN SHORT O
0N/A (byte)229,NO_CHAR, //094b -- DEVANAGARI VOWEL SIGN O
0N/A (byte)230,NO_CHAR, //094c -- DEVANAGARI VOWEL SIGN AU
0N/A (byte)232,NO_CHAR, //094d -- DEVANAGARI SIGN VIRAMA ( halant )
0N/A NO_CHAR,NO_CHAR, //094e <reserved>
0N/A NO_CHAR,NO_CHAR, //094f <reserved>
0N/A (byte)161,(byte)233, //0950 -- DEVANAGARI OM
0N/A (byte)240,(byte)181, //0951 -- DEVANAGARI STRESS SIGN UDATTA
0N/A (byte)240,(byte)184, //0952 -- DEVANAGARI STRESS SIGN ANUDATTA
0N/A (byte)254,NO_CHAR, //0953 -- DEVANAGARI GRAVE ACCENT || MISSING
0N/A (byte)254,NO_CHAR, //0954 -- DEVANAGARI ACUTE ACCENT || MISSING
0N/A NO_CHAR,NO_CHAR, //0955 <reserved>
0N/A NO_CHAR,NO_CHAR, //0956 <reserved>
0N/A NO_CHAR,NO_CHAR, //0957 <reserved>
0N/A (byte)179,(byte)233, //0958 -- DEVANAGARI LETTER QA <=> 0915 + 093C
0N/A (byte)180,(byte)233, //0959 -- DEVANAGARI LETTER KHHA <=> 0916 + 093C
0N/A (byte)181,(byte)233, //095a -- DEVANAGARI LETTER GHHA <=> 0917 + 093C
0N/A (byte)186,(byte)233, //095b -- DEVANAGARI LETTER ZA <=> 091C + 093C
0N/A (byte)191,(byte)233, //095c -- DEVANAGARI LETTER DDDHA <=> 0921 + 093C
0N/A (byte)192,(byte)233, //095d -- DEVANAGARI LETTER RHA <=> 0922 + 093C
0N/A (byte)201,(byte)233, //095e -- DEVANAGARI LETTER FA <=> 092B + 093C
0N/A (byte)206,NO_CHAR, //095f -- DEVANAGARI LETTER YYA <=> 092F + 093C
0N/A (byte)170,(byte)233, //0960 -- DEVANAGARI LETTER VOCALIC RR
0N/A (byte)167,(byte)233, //0961 -- DEVANAGARI LETTER VOCALIC LL
0N/A (byte)219,(byte)233, //0962 -- DEVANAGARI VOWEL SIGN VOCALIC L
0N/A (byte)220,(byte)233, //0963 -- DEVANAGARI VOWEL SIGN VOCALIC LL
0N/A (byte)234,NO_CHAR, //0964 -- DEVANAGARI DANDA ( phrase separator )
0N/A (byte)234,(byte)234, //0965 -- DEVANAGARI DOUBLE DANDA
0N/A (byte)241,NO_CHAR, //0966 -- DEVANAGARI DIGIT ZERO
0N/A (byte)242,NO_CHAR, //0967 -- DEVANAGARI DIGIT ONE
0N/A (byte)243,NO_CHAR, //0968 -- DEVANAGARI DIGIT TWO
0N/A (byte)244,NO_CHAR, //0969 -- DEVANAGARI DIGIT THREE
0N/A (byte)245,NO_CHAR, //096a -- DEVANAGARI DIGIT FOUR
0N/A (byte)246,NO_CHAR, //096b -- DEVANAGARI DIGIT FIVE
0N/A (byte)247,NO_CHAR, //096c -- DEVANAGARI DIGIT SIX
0N/A (byte)248,NO_CHAR, //096d -- DEVANAGARI DIGIT SEVEN
0N/A (byte)249,NO_CHAR, //096e -- DEVANAGARI DIGIT EIGHT
0N/A (byte)250,NO_CHAR, //096f -- DEVANAGARI DIGIT NINE
0N/A (byte)240,(byte)191, //0970 -- DEVANAGARI ABBREVIATION SIGN
0N/A NO_CHAR,NO_CHAR, //0971 -- reserved
0N/A NO_CHAR,NO_CHAR, //0972 -- reserved
0N/A NO_CHAR,NO_CHAR, //0973 -- reserved
0N/A NO_CHAR,NO_CHAR, //0974 -- reserved
0N/A NO_CHAR,NO_CHAR, //0975 -- reserved
0N/A NO_CHAR,NO_CHAR, //0976 -- reserved
0N/A NO_CHAR,NO_CHAR, //0977 -- reserved
0N/A NO_CHAR,NO_CHAR, //0978 -- reserved
0N/A NO_CHAR,NO_CHAR, //0979 -- reserved
0N/A NO_CHAR,NO_CHAR, //097a -- reserved
0N/A NO_CHAR,NO_CHAR, //097b -- reserved
0N/A NO_CHAR,NO_CHAR, //097c -- reserved
0N/A NO_CHAR,NO_CHAR, //097d -- reserved
0N/A NO_CHAR,NO_CHAR, //097e -- reserved
0N/A NO_CHAR,NO_CHAR //097f -- reserved
0N/A }; //end of table definition
0N/A
0N/A
0N/A /**
0N/A * This accessor is temporarily supplied while sun.io
0N/A * converters co-exist with the sun.nio.cs.{ext} charset coders
0N/A * These facilitate sharing of conversion tables between the
0N/A * two co-existing implementations. When sun.io converters
0N/A * are made extinct these will be unnecessary and should be removed
0N/A */
0N/A
0N/A public static byte[] getEncoderMappingTable() {
0N/A return encoderMappingTable;
0N/A }
0N/A
0N/A
0N/A private static class Decoder extends CharsetDecoder {
0N/A
0N/A private static final char ZWNJ_CHAR = '\u200c';
0N/A private static final char ZWJ_CHAR = '\u200d';
0N/A private static final char INVALID_CHAR = '\uffff';
0N/A
0N/A private char contextChar = INVALID_CHAR;
0N/A private boolean needFlushing = false;
0N/A
0N/A
0N/A private Decoder(Charset cs) {
0N/A super(cs, 1.0f, 1.0f);
0N/A }
0N/A
0N/A protected CoderResult implFlush(CharBuffer out) {
0N/A if(needFlushing) {
0N/A if (out.remaining() < 1) {
0N/A return CoderResult.OVERFLOW;
0N/A } else {
0N/A out.put(contextChar);
0N/A }
0N/A }
0N/A contextChar = INVALID_CHAR;
0N/A needFlushing = false;
0N/A return CoderResult.UNDERFLOW;
0N/A }
0N/A
0N/A /*Rules:
0N/A * 1)ATR,EXT,following character to be replaced with '\ufffd'
0N/A * 2)Halant + Halant => '\u094d' (Virama) + '\u200c'(ZWNJ)
0N/A * 3)Halant + Nukta => '\u094d' (Virama) + '\u200d'(ZWJ)
0N/A */
0N/A private CoderResult decodeArrayLoop(ByteBuffer src,
0N/A CharBuffer dst)
0N/A {
0N/A byte[] sa = src.array();
0N/A int sp = src.arrayOffset() + src.position();
0N/A int sl = src.arrayOffset() + src.limit();
0N/A assert (sp <= sl);
0N/A sp = (sp <= sl ? sp : sl);
0N/A
0N/A char[] da = dst.array();
0N/A int dp = dst.arrayOffset() + dst.position();
0N/A int dl = dst.arrayOffset() + dst.limit();
0N/A assert (dp <= dl);
0N/A dp = (dp <= dl ? dp : dl);
0N/A
0N/A try {
0N/A while (sp < sl) {
0N/A int index = sa[sp];
0N/A index = ( index < 0 )? ( index + 255 ):index;
0N/A char currentChar = directMapTable[index];
0N/A
0N/A // if the contextChar is either ATR || EXT
0N/A // set the output to '\ufffd'
0N/A if(contextChar == '\ufffd') {
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A da[dp++] = '\ufffd';
0N/A contextChar = INVALID_CHAR;
0N/A needFlushing = false;
0N/A sp++;
0N/A continue;
0N/A }
0N/A
0N/A switch(currentChar) {
0N/A case '\u0901':
0N/A case '\u0907':
0N/A case '\u0908':
0N/A case '\u090b':
0N/A case '\u093f':
0N/A case '\u0940':
0N/A case '\u0943':
0N/A case '\u0964':
0N/A if(needFlushing) {
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A da[dp++] = contextChar;
0N/A contextChar = currentChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A contextChar = currentChar;
0N/A needFlushing = true;
0N/A sp++;
0N/A continue;
0N/A case NUKTA_CHAR:
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A switch(contextChar) {
0N/A case '\u0901':
0N/A da[dp++] = '\u0950';
0N/A break;
0N/A case '\u0907':
0N/A da[dp++] = '\u090c';
0N/A break;
0N/A case '\u0908':
0N/A da[dp++] = '\u0961';
0N/A break;
0N/A case '\u090b':
0N/A da[dp++] = '\u0960';
0N/A break;
0N/A case '\u093f':
0N/A da[dp++] = '\u0962';
0N/A break;
0N/A case '\u0940':
0N/A da[dp++] = '\u0963';
0N/A break;
0N/A case '\u0943':
0N/A da[dp++] = '\u0944';
0N/A break;
0N/A case '\u0964':
0N/A da[dp++] = '\u093d';
0N/A break;
0N/A case HALANT_CHAR:
0N/A if(needFlushing) {
0N/A da[dp++] = contextChar;
0N/A contextChar = currentChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A da[dp++] = ZWJ_CHAR;
0N/A break;
0N/A default:
0N/A if(needFlushing) {
0N/A da[dp++] = contextChar;
0N/A contextChar = currentChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A da[dp++] = NUKTA_CHAR;
0N/A }
0N/A break;
0N/A case HALANT_CHAR:
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A if(needFlushing) {
0N/A da[dp++] = contextChar;
0N/A contextChar = currentChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A if(contextChar == HALANT_CHAR) {
0N/A da[dp++] = ZWNJ_CHAR;
0N/A break;
0N/A }
0N/A da[dp++] = HALANT_CHAR;
0N/A break;
0N/A case INVALID_CHAR:
0N/A if(needFlushing) {
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A da[dp++] = contextChar;
0N/A contextChar = currentChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A return CoderResult.unmappableForLength(1);
0N/A default:
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A if(needFlushing) {
0N/A da[dp++] = contextChar;
0N/A contextChar = currentChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A da[dp++] = currentChar;
0N/A break;
0N/A }//end switch
0N/A
0N/A contextChar = currentChar;
0N/A needFlushing = false;
0N/A sp++;
0N/A }
0N/A return CoderResult.UNDERFLOW;
0N/A } finally {
0N/A src.position(sp - src.arrayOffset());
0N/A dst.position(dp - dst.arrayOffset());
0N/A }
0N/A }
0N/A
0N/A private CoderResult decodeBufferLoop(ByteBuffer src,
0N/A CharBuffer dst)
0N/A {
0N/A int mark = src.position();
0N/A
0N/A try {
0N/A while (src.hasRemaining()) {
0N/A int index = src.get();
0N/A index = ( index < 0 )? ( index + 255 ):index;
0N/A char currentChar = directMapTable[index];
0N/A
0N/A // if the contextChar is either ATR || EXT
0N/A // set the output to '\ufffd'
0N/A if(contextChar == '\ufffd') {
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A dst.put('\ufffd');
0N/A contextChar = INVALID_CHAR;
0N/A needFlushing = false;
0N/A mark++;
0N/A continue;
0N/A }
0N/A
0N/A switch(currentChar) {
0N/A case '\u0901':
0N/A case '\u0907':
0N/A case '\u0908':
0N/A case '\u090b':
0N/A case '\u093f':
0N/A case '\u0940':
0N/A case '\u0943':
0N/A case '\u0964':
0N/A if(needFlushing) {
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A dst.put(contextChar);
0N/A contextChar = currentChar;
0N/A mark++;
0N/A continue;
0N/A }
0N/A contextChar = currentChar;
0N/A needFlushing = true;
0N/A mark++;
0N/A continue;
0N/A case NUKTA_CHAR:
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A switch(contextChar) {
0N/A case '\u0901':
0N/A dst.put('\u0950');
0N/A break;
0N/A case '\u0907':
0N/A dst.put('\u090c');
0N/A break;
0N/A case '\u0908':
0N/A dst.put('\u0961');
0N/A break;
0N/A case '\u090b':
0N/A dst.put('\u0960');
0N/A break;
0N/A case '\u093f':
0N/A dst.put('\u0962');
0N/A break;
0N/A case '\u0940':
0N/A dst.put('\u0963');
0N/A break;
0N/A case '\u0943':
0N/A dst.put('\u0944');
0N/A break;
0N/A case '\u0964':
0N/A dst.put('\u093d');
0N/A break;
0N/A case HALANT_CHAR:
0N/A if(needFlushing) {
0N/A dst.put(contextChar);
0N/A contextChar = currentChar;
0N/A mark++;
0N/A continue;
0N/A }
0N/A dst.put(ZWJ_CHAR);
0N/A break;
0N/A default:
0N/A if(needFlushing) {
0N/A dst.put(contextChar);
0N/A contextChar = currentChar;
0N/A mark++;
0N/A continue;
0N/A }
0N/A dst.put(NUKTA_CHAR);
0N/A }
0N/A break;
0N/A case HALANT_CHAR:
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A if(needFlushing) {
0N/A dst.put(contextChar);
0N/A contextChar = currentChar;
0N/A mark++;
0N/A continue;
0N/A }
0N/A if(contextChar == HALANT_CHAR) {
0N/A dst.put(ZWNJ_CHAR);
0N/A break;
0N/A }
0N/A dst.put(HALANT_CHAR);
0N/A break;
0N/A case INVALID_CHAR:
0N/A if(needFlushing) {
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A dst.put(contextChar);
0N/A contextChar = currentChar;
0N/A mark++;
0N/A continue;
0N/A }
0N/A return CoderResult.unmappableForLength(1);
0N/A default:
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A if(needFlushing) {
0N/A dst.put(contextChar);
0N/A contextChar = currentChar;
0N/A mark++;
0N/A continue;
0N/A }
0N/A dst.put(currentChar);
0N/A break;
0N/A }//end switch
0N/A contextChar = currentChar;
0N/A needFlushing = false;
0N/A mark++;
0N/A }
0N/A return CoderResult.UNDERFLOW;
0N/A } finally {
0N/A src.position(mark);
0N/A }
0N/A }
0N/A
0N/A protected CoderResult decodeLoop(ByteBuffer src,
0N/A CharBuffer dst)
0N/A {
0N/A if (src.hasArray() && dst.hasArray())
0N/A return decodeArrayLoop(src, dst);
0N/A else
0N/A return decodeBufferLoop(src, dst);
0N/A }
0N/A }
0N/A
0N/A private static class Encoder extends CharsetEncoder {
0N/A
0N/A private static final byte NO_CHAR = (byte)255;
0N/A
0N/A //private static CharToByteISCII91 c2b = new CharToByteISCII91();
0N/A //private static final byte[] directMapTable = c2b.getISCIIEncoderMap();
0N/A
0N/A private final Surrogate.Parser sgp = new Surrogate.Parser();
0N/A
0N/A private Encoder(Charset cs) {
0N/A super(cs, 2.0f, 2.0f);
0N/A }
0N/A
0N/A public boolean canEncode(char ch) {
0N/A //check for Devanagari range,ZWJ,ZWNJ and ASCII range.
0N/A return ((ch >= '\u0900' && ch <= '\u097f' &&
0N/A encoderMappingTable[2*(ch-'\u0900')] != NO_CHAR) ||
0N/A (ch == '\u200d') ||
0N/A (ch == '\u200c') ||
0N/A (ch <= '\u007f'));
0N/A }
0N/A
0N/A
0N/A private CoderResult encodeArrayLoop(CharBuffer src,
0N/A ByteBuffer dst)
0N/A {
0N/A char[] sa = src.array();
0N/A int sp = src.arrayOffset() + src.position();
0N/A int sl = src.arrayOffset() + src.limit();
0N/A assert (sp <= sl);
0N/A sp = (sp <= sl ? sp : sl);
0N/A byte[] da = dst.array();
0N/A int dp = dst.arrayOffset() + dst.position();
0N/A int dl = dst.arrayOffset() + dst.limit();
0N/A assert (dp <= dl);
0N/A dp = (dp <= dl ? dp : dl);
0N/A
0N/A int outputSize = 0;
0N/A
0N/A try {
0N/A char inputChar;
0N/A while (sp < sl) {
0N/A int index = Integer.MIN_VALUE;
0N/A inputChar = sa[sp];
0N/A
0N/A if (inputChar >= 0x0000 && inputChar <= 0x007f) {
0N/A if (dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A da[dp++] = (byte) inputChar;
0N/A sp++;
0N/A continue;
0N/A }
0N/A
0N/A // if inputChar == ZWJ replace it with halant
0N/A // if inputChar == ZWNJ replace it with Nukta
0N/A
0N/A if (inputChar == 0x200c) {
0N/A inputChar = HALANT_CHAR;
0N/A }
0N/A else if (inputChar == 0x200d) {
0N/A inputChar = NUKTA_CHAR;
0N/A }
0N/A
0N/A if (inputChar >= 0x0900 && inputChar <= 0x097f) {
0N/A index = ((int)(inputChar) - 0x0900)*2;
0N/A }
0N/A
1602N/A if (Character.isSurrogate(inputChar)) {
0N/A if (sgp.parse(inputChar, sa, sp, sl) < 0)
0N/A return sgp.error();
0N/A return sgp.unmappableResult();
0N/A }
0N/A
0N/A if (index == Integer.MIN_VALUE ||
0N/A encoderMappingTable[index] == NO_CHAR) {
0N/A return CoderResult.unmappableForLength(1);
0N/A } else {
0N/A if(encoderMappingTable[index + 1] == NO_CHAR) {
0N/A if(dl - dp < 1)
0N/A return CoderResult.OVERFLOW;
0N/A da[dp++] = encoderMappingTable[index];
0N/A } else {
0N/A if(dl - dp < 2)
0N/A return CoderResult.OVERFLOW;
0N/A da[dp++] = encoderMappingTable[index];
0N/A da[dp++] = encoderMappingTable[index + 1];
0N/A }
0N/A sp++;
0N/A }
0N/A }
0N/A return CoderResult.UNDERFLOW;
0N/A } finally {
0N/A src.position(sp - src.arrayOffset());
0N/A dst.position(dp - dst.arrayOffset());
0N/A }
0N/A }
0N/A
0N/A private CoderResult encodeBufferLoop(CharBuffer src,
0N/A ByteBuffer dst)
0N/A {
0N/A int mark = src.position();
0N/A
0N/A try {
0N/A char inputChar;
0N/A while (src.hasRemaining()) {
0N/A int index = Integer.MIN_VALUE;
0N/A inputChar = src.get();
0N/A
0N/A if (inputChar >= 0x0000 && inputChar <= 0x007f) {
0N/A if (dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A dst.put((byte) inputChar);
0N/A mark++;
0N/A continue;
0N/A }
0N/A
0N/A // if inputChar == ZWJ replace it with halant
0N/A // if inputChar == ZWNJ replace it with Nukta
0N/A
0N/A if (inputChar == 0x200c) {
0N/A inputChar = HALANT_CHAR;
0N/A }
0N/A else if (inputChar == 0x200d) {
0N/A inputChar = NUKTA_CHAR;
0N/A }
0N/A
0N/A if (inputChar >= 0x0900 && inputChar <= 0x097f) {
0N/A index = ((int)(inputChar) - 0x0900)*2;
0N/A }
0N/A
1602N/A if (Character.isSurrogate(inputChar)) {
0N/A if (sgp.parse(inputChar, src) < 0)
0N/A return sgp.error();
0N/A return sgp.unmappableResult();
0N/A }
0N/A
0N/A if (index == Integer.MIN_VALUE ||
0N/A encoderMappingTable[index] == NO_CHAR) {
0N/A return CoderResult.unmappableForLength(1);
0N/A } else {
0N/A if(encoderMappingTable[index + 1] == NO_CHAR) {
0N/A if(dst.remaining() < 1)
0N/A return CoderResult.OVERFLOW;
0N/A dst.put(encoderMappingTable[index]);
0N/A } else {
0N/A if(dst.remaining() < 2)
0N/A return CoderResult.OVERFLOW;
0N/A dst.put(encoderMappingTable[index]);
0N/A dst.put(encoderMappingTable[index + 1]);
0N/A }
0N/A }
0N/A mark++;
0N/A }
0N/A return CoderResult.UNDERFLOW;
0N/A } finally {
0N/A src.position(mark);
0N/A }
0N/A }
0N/A
0N/A protected CoderResult encodeLoop(CharBuffer src,
0N/A ByteBuffer dst)
0N/A {
0N/A if (src.hasArray() && dst.hasArray())
0N/A return encodeArrayLoop(src, dst);
0N/A else
0N/A return encodeBufferLoop(src, dst);
0N/A }
0N/A }
0N/A}