< prev index next >

src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template

Print this page




12502                             break;
12503                         case GB18030_FOUR_BYTE:
12504                             int offset = (((byte1 - 0x81) * 10 +
12505                                            (byte2 - 0x30)) * 126 +
12506                                             byte3 - 0x81) * 10 + byte4 - 0x30;
12507                             int hiByte = (offset >>8) & 0xFF;
12508                             int lowByte = (offset & 0xFF);
12509 
12510                         // Mixture of table lookups and algorithmic calculation
12511                         // of character values.
12512 
12513                         // BMP Ranges
12514                         if (offset <= 0x4A62)
12515                             dst.put(getChar(offset));
12516                         else if (offset > 0x4A62 && offset <= 0x82BC)
12517                             dst.put((char)(offset + 0x5543));
12518                         else if (offset >= 0x82BD && offset <= 0x830D)
12519                             dst.put(getChar(offset));
12520                         else if (offset >= 0x830D && offset <= 0x93A8)
12521                             dst.put((char)(offset + 0x6557));
12522                         else if (offset >= 0x93A9 && offset <= 0x99F9)
12523                             dst.put(getChar(offset));
12524                         // Supplemental UCS planes handled via surrogates
12525                         else if (offset >= 0x2E248 && offset < 0x12E248) {
12526                             if (offset >= 0x12E248)
12527                                 return CoderResult.malformedForLength(4);
12528                             offset -= 0x1e248;
12529                             if ( dst.remaining() < 2)
12530                                 return CoderResult.OVERFLOW;
12531                             // emit high + low surrogate
12532                             dst.put((char)((offset - 0x10000) / 0x400 + 0xD800));
12533                             dst.put((char)((offset - 0x10000) % 0x400 + 0xDC00));
12534                         } else {
12535                             return CoderResult.malformedForLength(inputSize);
12536                         }
12537                     }
12538                     mark += inputSize;
12539                 }
12540                 return CoderResult.UNDERFLOW;
12541             } finally {
12542                 src.position(mark);




12502                             break;
12503                         case GB18030_FOUR_BYTE:
12504                             int offset = (((byte1 - 0x81) * 10 +
12505                                            (byte2 - 0x30)) * 126 +
12506                                             byte3 - 0x81) * 10 + byte4 - 0x30;
12507                             int hiByte = (offset >>8) & 0xFF;
12508                             int lowByte = (offset & 0xFF);
12509 
12510                         // Mixture of table lookups and algorithmic calculation
12511                         // of character values.
12512 
12513                         // BMP Ranges
12514                         if (offset <= 0x4A62)
12515                             dst.put(getChar(offset));
12516                         else if (offset > 0x4A62 && offset <= 0x82BC)
12517                             dst.put((char)(offset + 0x5543));
12518                         else if (offset >= 0x82BD && offset <= 0x830D)
12519                             dst.put(getChar(offset));
12520                         else if (offset >= 0x830D && offset <= 0x93A8)
12521                             dst.put((char)(offset + 0x6557));
12522                         else if (offset >= 0x93A9 && offset <= 0x99FB)
12523                             dst.put(getChar(offset));
12524                         // Supplemental UCS planes handled via surrogates
12525                         else if (offset >= 0x2E248 && offset < 0x12E248) {
12526                             if (offset >= 0x12E248)
12527                                 return CoderResult.malformedForLength(4);
12528                             offset -= 0x1e248;
12529                             if ( dst.remaining() < 2)
12530                                 return CoderResult.OVERFLOW;
12531                             // emit high + low surrogate
12532                             dst.put((char)((offset - 0x10000) / 0x400 + 0xD800));
12533                             dst.put((char)((offset - 0x10000) % 0x400 + 0xDC00));
12534                         } else {
12535                             return CoderResult.malformedForLength(inputSize);
12536                         }
12537                     }
12538                     mark += inputSize;
12539                 }
12540                 return CoderResult.UNDERFLOW;
12541             } finally {
12542                 src.position(mark);


< prev index next >