public String decode(String s) throws CannotDecodeException
  {
    if (s == null)
    {
      return null;
    }
    StringBuilder sb = new StringBuilder();
    int len = s.length();
    for (int i = 0; i < len; i++)
    {
      char c = s.charAt(i);

      if (c == _encodingChar)
      {
        if (i + 3 > len)
        {
          throw new CannotDecodeException(s + " - Failed to decode incomplete escaped char at offset " + i);
        }
        String asciiHex = s.substring(i + 1, i + 3);
        try
        {
          Integer asciiInt = Integer.parseInt(asciiHex, 16);
          sb.append((char) asciiInt.intValue());
        }
        catch (NumberFormatException ex)
        {
          throw new CannotDecodeException(s + " - Failed to decode escaped char at offset " + i);
        }
        i += 2;
      }
      else
      {
        sb.append(c);
      }
    }

    return sb.toString();
  }
@Test
  public void testSingleCharDecode() throws Exception
  {
    Assert.assertEquals(TEST_ENCODING_1.decode("~2E"), ".");
    Assert.assertEquals(TEST_ENCODING_1.decode("~5B"), "[");
    Assert.assertEquals(TEST_ENCODING_1.decode("~5D"), "]");
    Assert.assertEquals(TEST_ENCODING_1.decode("~7E"), "~");
    Assert.assertEquals(TEST_ENCODING_1.decode("~10"), "\020"); // first char that does not require 0 padding
    Assert.assertEquals(TEST_ENCODING_1.decode("~0F"), "\017"); // last char that requires 0 padding
  }