Exemple #1
0
  public static void testEncode(String input, String encoding) throws XcodeException {
    String inputdecoded = null;
    String output = null;
    String variant = null;

    if (input == null) {
      Debug.pass("");
      return;
    }
    input = input.trim();

    if (input.length() == 0 || input.charAt(0) == '#') {
      Debug.pass(input);
      return;
    }

    try {
      inputdecoded = new String(Hex.decodeChars(input));
      output = Native.encode(inputdecoded, encoding);
    } catch (XcodeException x) {
      Debug.fail(input + "	ERROR:" + x.getCode() + "	" + x.getMessage());
      return;
    }

    System.out.println(Hex.encode(output.toCharArray()));
  }
Exemple #2
0
  public static void testEncode(String input, String[] encodings) throws XcodeException {
    String inputdecoded = null;
    HashMap output = null;
    String variant = null;

    if (input == null) {
      Debug.pass("");
      return;
    }
    input = input.trim();

    if (input.length() == 0 || input.charAt(0) == '#') {
      Debug.pass(input);
      return;
    }

    try {
      inputdecoded = new String(Hex.decodeChars(input));
      if (encodings == null || encodings.length == 0) {
        output = Native.encode(inputdecoded);
      } else {
        output = Native.encode(inputdecoded, encodings);
      }
    } catch (XcodeException x) {
      Debug.fail(input + "	ERROR:" + x.getCode() + "	" + x.getMessage());
      return;
    }

    System.out.println(input);
    Iterator i = output.keySet().iterator();
    String encoding = null;
    while (i.hasNext()) {
      encoding = (String) i.next();
      variant = (String) output.get(encoding);
      System.out.println("	" + encoding + "	" + Hex.encode(variant.toCharArray()));
    }
    System.out.println(output.size());
  }