cdm/src/main/java/ucar/nc2/util/EscapeStrings.java
static public String backslashEscapeDapString(String s) {
    StringBuilder buf = new StringBuilder();
    for(int i=0;i<s.length();i++) {
	int c = s.charAt(i);
        if(true) {
            if(c < ' ') {
                switch (c) {
                case '\n': case '\r': case '\t': case '\f':
                    buf.append((char)c);
                    break;
                default:
                    buf.append(String.format("\\x%02x",(c&0xff)));
                    break;
                }
                continue;
            }
        }
        if(c == '"') {
            buf.append("\\\"");
        } else if(c == '\\') {
            buf.append("\\\\");
        } else
            buf.append((char)c);
    }
    return buf.toString();
  }
static public String backslashEscapeDapString(String s) {
    StringBuilder buf = new StringBuilder();
    for(int i=0;i<s.length();i++) {
	int c = s.charAt(i);
        if(true) {
            if(c < ' ') {
                switch (c) {
                case '\n': case '\r': case '\t': case '\f':
                    buf.append((char)c);
                    break;
                default:
                    buf.append(String.format("\\x%02x",(c&0xff)));
                    break;
                }
                continue;
            }
        }
        if(c == '"') {
            buf.append("\\\"");
        } else if(c == '\\') {
            buf.append("\\\\");
        } else
            buf.append((char)c);
    }
    return buf.toString();
  }
Given a DAP (attribute) string, insert backslashes
before '"' and '/' characters. This code also escapes
control characters, although the spec does not call for it;
make that code conditional.