opendap/src/main/java/opendap/dap/Util.java
static String escattr(String s) {
        StringBuffer buf = new StringBuffer(s.length());
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == ' ' || (c >= '!' && c <= '~')) {
                // printable ASCII character
                buf.append(c);
            } else {
                // non-printable ASCII character: print as unsigned octal integer
                // padded with leading zeros
                buf.append('\\');
                String numVal = Integer.toString((int) c & 0xFF, 8);
                for (int pad = 0; pad < (3 - numVal.length()); pad++)
                    buf.append('0');
                buf.append(numVal);
            }
        }
        return buf.toString();
    }
static String escattr(String s) {
        StringBuffer buf = new StringBuffer(s.length());
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == ' ' || (c >= '!' && c <= '~')) {
                // printable ASCII character
                buf.append(c);
            } else {
                // non-printable ASCII character: print as unsigned octal integer
                // padded with leading zeros
                buf.append('\\');
                String numVal = Integer.toString((int) c & 0xFF, 8);
                for (int pad = 0; pad < (3 - numVal.length()); pad++)
                    buf.append('0');
                buf.append(numVal);
            }
        }
        return buf.toString();
    }
static String escattr ( String s ) { StringBuffer buf = new StringBuffer ( s . length ( ) ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == ' ' || ( c >= ' ' && c <= ' ' ) ) { // printable ASCII character buf . append ( c ) ; } else { // non-printable ASCII character: print as unsigned octal integer // padded with leading zeros buf . append ( ' ' ) ; String numVal = Integer . toString ( ( int ) c & 0xFF , 8 ) ; for ( int pad = 0 ; pad < ( 3 - numVal . length ( ) ) ; pad ++ ) buf . append ( ' ' ) ; buf . append ( numVal ) ; } } return buf . toString ( ) ; }
This function escapes non-printable characters and quotes.  This is used
to make <code>printVal</code> output <code>DString</code> data in the
same way as the C++ version.  Since Java supports Unicode, this will
need to be altered if it's desired to print <code>DString</code> as
UTF-8 or some other character encoding.

@param s the input <code>String</code>.
@return the escaped <code>String</code>.
This function escapes non - printable characters and quotes . This is used to make <code > printVal< / code > output <code > DString< / code > data in the same way as the C ++ version . Since Java supports Unicode this will need to be altered if it s desired to print <code > DString< / code > as UTF - 8 or some other character encoding .