Example #1
0
  public static void main(String[] args) throws Exception {
    for (String csname : csnames) {
      System.out.printf("-----------------------------------%n");
      String oldname = csname + "_OLD";
      checkInit(csname);
      Charset csOld = (Charset) Class.forName(oldname).newInstance();
      Charset csNew = Charset.forName(csname);
      char[] cc = checkEncoding(csOld, csNew);
      checkDecoding(csOld, csNew);
      compare(csNew, csOld, cc);

      if (csname.startsWith("x-IBM93")) {
        // ecdbic
        checkMalformed(
            csNew,
            new byte[][] {
              {1, 0x26, 0x0f, 0x27}, // in SBSC, no SI
              {1, 0x0e, 0x41, 0x41, 0xe}, // in DBSC, no SO
              {2, 0x0e, 0x40, 0x41, 0xe}, // illegal DB
            });
      } else if (csname.equals("x-IBM970") || csname.equals("x-IBM1383")) {
        // euc_simple
        checkMalformed(
            csNew,
            new byte[][] {
              {1, 0x26, (byte) 0x8f, 0x27}, // SS2
              {1, (byte) 0xa1, (byte) 0xa1, (byte) 0x8e, 0x51}, // SS3
            });
      }
    }
  }