private static StringBuilder escape(String in, StringBuilder escaped) {
        for (char c : in.toCharArray()) {
            switch (c) {
            case ('\b'):
                escaped.append("\\b");
                break;
            case ('\t'):
                escaped.append("\\t");
                break;
            case ('\n'):
                escaped.append("\\n");
                break;
            case ('\f'):
                escaped.append("\\f");
                break;
            case ('\r'):
                escaped.append("\\r");
                break;
            case ('"'):
                escaped.append("\\\"");
                break;
            case ('\''):
                escaped.append("\\'");
                break;
            case ('\\'):
                escaped.append("\\\\");
                break;
            case ('/'):
                escaped.append("\\/");
                break;
            default:
                if (c < 32 || c >= 127) {
                    escaped.append("\\u").append(fourDigitHexString(c));
                } else {
                    escaped.append(c);
                }
            }
        }
        return escaped;
    }
Do YQL+ escaping, which is basically the same as for JSON, of the
incoming string to the "quoted" buffer. The buffer returned is the same
as the one given in the "quoted" parameter.

@param in a string to escape
@param escaped the target buffer for escaped data
@return the same buffer as given in the "quoted" parameter
container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java