code: private static char readUnicode(StringBuilder inBuf, int i) {
      int r = 0;
      for (int j = i; j < i + 4; j++) {
        char atJ = inBuf.charAt(j);
  
        if (atJ >= '0' && atJ <= '9') {
          r = (r << 4) + atJ - '0';
          continue;
        }
        if (atJ >= 'A' && atJ <= 'F') {
          // '7' = 'A' - 10
          r = (r << 4) + atJ - '7';
          continue;
        }
        if (atJ >= 'a' && atJ <= 'f') {
          // 'W' = 'a' - 10
          r = (r << 4) + atJ - 'W';
          continue;
        }
      }
      return (char) r;
    }
docs: see http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#95504