if (C < 0xD800 || C > 0xDBFF) { V = C;
if (c < 0xD800 || c > 0xDBFF) { v = c;
Encode(JSContext *cx, JSString *str, const jschar *unescapedSet,       const jschar *unescapedSet2, jsval *rval){    size_t length, j, k, L;    jschar *chars, C, C2;    uint32 V;    uint8 utf8buf[6];    jschar hexBuf[4];    static const char HexDigits[] = "0123456789ABCDEF"; /* NB: uppercase */    JSString *R;    length = JSSTRING_LENGTH(str);    if (length == 0) {        *rval = STRING_TO_JSVAL(cx->runtime->emptyString);        return JS_TRUE;    }    R = js_NewString(cx, NULL, 0, 0);    if (!R)        return JS_FALSE;    hexBuf[0] = '%';    hexBuf[3] = 0;    chars = JSSTRING_CHARS(str);    for (k = 0; k < length; k++) {        C = chars[k];        if (js_strchr(unescapedSet, C) ||            (unescapedSet2 && js_strchr(unescapedSet2, C))) {            if (!AddCharsToURI(cx, R, &C, 1))                return JS_FALSE;        } else {            if ((C >= 0xDC00) && (C <= 0xDFFF)) {                JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,                                 JSMSG_BAD_URI, NULL);                return JS_FALSE;            }            if (C < 0xD800 || C > 0xDBFF) {                V = C;            } else {                k++;                if (k == length) {                    JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,                                     JSMSG_BAD_URI, NULL);                    return JS_FALSE;                }                C2 = chars[k];                if ((C2 < 0xDC00) || (C2 > 0xDFFF)) {                    JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,                                     JSMSG_BAD_URI, NULL);                    return JS_FALSE;                }                V = ((C - 0xD800) << 10) + (C2 - 0xDC00) + 0x10000;            }            L = OneUcs4ToUtf8Char(utf8buf, V);            for (j = 0; j < L; j++) {                hexBuf[1] = HexDigits[utf8buf[j] >> 4];                hexBuf[2] = HexDigits[utf8buf[j] & 0xf];                if (!AddCharsToURI(cx, R, hexBuf, 3))                    return JS_FALSE;            }        }    }    /*     * Shrinking realloc can fail (e.g., with a BSD-style allocator), but we     * don't worry about that case here.  Worst case, R hangs onto URI_CHUNK-1     * more jschars than it needs.     */    chars = (jschar *) JS_realloc(cx, R->chars, (R->length+1) * sizeof(jschar));    if (chars)        R->chars = chars;    *rval = STRING_TO_JSVAL(R);    return JS_TRUE;}