Example #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()));
  }
Example #2
0
  public static void testDecode(String input, String[] encodings) throws XcodeException {
    byte[] inputarray = 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 {
      inputarray = Hex.decodeBytes(input);
      if (encodings == null || encodings.length == 0) {
        output = Native.decode(inputarray);
      } else {
        output = Native.decode(inputarray, 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());
  }