def escapeAttrJavaScriptStringDQ(sText):
    """ Escapes a javascript string that is to be emitted between double quotes. """
    if '"' not in sText:
        chMin = min(sText);
        if ord(chMin) >= 0x20:
            return sText;

    sRet = '';
    for ch in sText:
        if ch == '"':
            sRet += '\\"';
        elif ord(ch) >= 0x20:
            sRet += ch;
        elif ch == '\n':
            sRet += '\\n';
        elif ch == '\r':
            sRet += '\\r';
        elif ch == '\t':
            sRet += '\\t';
        else:
            sRet += '\\x%02x' % (ch,);
    return sRet;