@Override
    public String toString() {
        StringBuilder buf = new StringBuilder();
        for (byte b : content) {
            int i = b;
            i &= 0xFF;
            char cv = (char)i;
            if ((i > 31 && i < 127) || cv == '\n' || cv == '\t') {
                buf.append(cv);
            } else if (i < 16) {
                buf.append("\\x0");
                buf.append(Integer.toHexString(i));
            } else if (i < 256) {
                buf.append("\\x");
                buf.append(Integer.toHexString(i));
            } else {
                // XXX maybe we should only do this? creates possibly-invalid XML though.
                buf.append("&");
                buf.append(i);
                buf.append(";");
            }
        }
        return buf.toString();
    }
An ascii string; non-ascii data is escaped with hex notation.
NB: not always uniquely reversible.
container-search/src/main/java/com/yahoo/prelude/hitfield/RawData.java