lib/Request.js
function encode(string) {
    function hex(code) {
        var hex_code = code.toString(16).toUpperCase();
        if (hex_code.length < 2) {
            hex_code = 0 + hex_code;
        }
        return '%' + hex_code;
    }

    string = string + '';
    var reserved_chars = /[ :\/?#\[\]@!$&'()*+,;=<>"{}|\\`\^%\r\n\u0080-\uffff]/;
    var str_len = string.length;
    var i;
    var string_arr = string.split('');
    var c;

    for (i = 0; i < str_len; i += 1) {
        if (c = string_arr[i].match(reserved_chars)) {
            c = c[0].charCodeAt(0);

            if (c < 128) {
                string_arr[i] = hex(c);
            } else if (c < 2048) {
                string_arr[i] = hex(192 + (c >> 6)) + hex(128 + (c & 63));
            } else if (c < 65536) {
                string_arr[i] = hex(224 + (c >> 12)) + hex(128 + ((c >> 6) & 63)) + hex(128 + (c & 63));
            } else if (c < 2097152) {
                string_arr[i] = hex(240 + (c >> 18)) + hex(128 + ((c >> 12) & 63)) + hex(128 + ((c >> 6) & 63)) + hex(128 + (c & 63));
            }
        }
    }

    return string_arr.join('');
}
function encode(string) {
    function hex(code) {
        var hex_code = code.toString(16).toUpperCase();
        if (hex_code.length < 2) {
            hex_code = 0 + hex_code;
        }
        return '%' + hex_code;
    }

    string = string + '';
    var reserved_chars = /[ :\/?#\[\]@!$&'()*+,;=<>"{}|\\`\^%\r\n\u0080-\uffff]/;
    var str_len = string.length;
    var i;
    var string_arr = string.split('');
    var c;

    for (i = 0; i < str_len; i += 1) {
        if (c = string_arr[i].match(reserved_chars)) {
            c = c[0].charCodeAt(0);

            if (c < 128) {
                string_arr[i] = hex(c);
            } else if (c < 2048) {
                string_arr[i] = hex(192 + (c >> 6)) + hex(128 + (c & 63));
            } else if (c < 65536) {
                string_arr[i] = hex(224 + (c >> 12)) + hex(128 + ((c >> 6) & 63)) + hex(128 + (c & 63));
            } else if (c < 2097152) {
                string_arr[i] = hex(240 + (c >> 18)) + hex(128 + ((c >> 12) & 63)) + hex(128 + ((c >> 6) & 63)) + hex(128 + (c & 63));
            }
        }
    }

    return string_arr.join('');
}
rfc3986 compatable encode of a string

@param {String} string