jdk/src/share/classes/sun/nio/cs/UTF_8.java
changeset 5986 04eb44085c00
parent 5506 202f599c92aa
child 5991 288afdbbca28
equal deleted inserted replaced
5985:f98ac682b34c 5986:04eb44085c00
   100 
   100 
   101         //  [F0]     [90..BF] [80..BF] [80..BF]
   101         //  [F0]     [90..BF] [80..BF] [80..BF]
   102         //  [F1..F3] [80..BF] [80..BF] [80..BF]
   102         //  [F1..F3] [80..BF] [80..BF] [80..BF]
   103         //  [F4]     [80..8F] [80..BF] [80..BF]
   103         //  [F4]     [80..8F] [80..BF] [80..BF]
   104         //  only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
   104         //  only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
   105         //  will be checked by Surrogate.neededFor(uc)
   105         //  will be checked by Character.isSupplementaryCodePoint(uc)
   106         private static boolean isMalformed4(int b2, int b3, int b4) {
   106         private static boolean isMalformed4(int b2, int b3, int b4) {
   107             return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
   107             return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
   108                    (b4 & 0xc0) != 0x80;
   108                    (b4 & 0xc0) != 0x80;
   109         }
   109         }
   110 
   110 
   246                     int uc = ((b1 & 0x07) << 18) |
   246                     int uc = ((b1 & 0x07) << 18) |
   247                              ((b2 & 0x3f) << 12) |
   247                              ((b2 & 0x3f) << 12) |
   248                              ((b3 & 0x3f) << 06) |
   248                              ((b3 & 0x3f) << 06) |
   249                              (b4 & 0x3f);
   249                              (b4 & 0x3f);
   250                     if (isMalformed4(b2, b3, b4) ||
   250                     if (isMalformed4(b2, b3, b4) ||
   251                         !Surrogate.neededFor(uc)) {
   251                         // shortest form check
       
   252                         !Character.isSupplementaryCodePoint(uc)) {
   252                         return malformed(src, sp, dst, dp, 4);
   253                         return malformed(src, sp, dst, dp, 4);
   253                     }
   254                     }
   254                     da[dp++] = Surrogate.high(uc);
   255                     da[dp++] = Surrogate.high(uc);
   255                     da[dp++] = Surrogate.low(uc);
   256                     da[dp++] = Surrogate.low(uc);
   256                     sp += 4;
   257                     sp += 4;
   302                     int uc = ((b1 & 0x07) << 18) |
   303                     int uc = ((b1 & 0x07) << 18) |
   303                              ((b2 & 0x3f) << 12) |
   304                              ((b2 & 0x3f) << 12) |
   304                              ((b3 & 0x3f) << 06) |
   305                              ((b3 & 0x3f) << 06) |
   305                              (b4 & 0x3f);
   306                              (b4 & 0x3f);
   306                     if (isMalformed4(b2, b3, b4) ||
   307                     if (isMalformed4(b2, b3, b4) ||
   307                         !Surrogate.neededFor(uc)) { // shortest form check
   308                         // shortest form check
       
   309                         !Character.isSupplementaryCodePoint(uc)) {
   308                         return malformed(src, mark, 4);
   310                         return malformed(src, mark, 4);
   309                     }
   311                     }
   310                     dst.put(Surrogate.high(uc));
   312                     dst.put(Surrogate.high(uc));
   311                     dst.put(Surrogate.low(uc));
   313                     dst.put(Surrogate.low(uc));
   312                     mark += 4;
   314                     mark += 4;