Encode data to DataURL
187984
def encode(data, mime_type='', charset='utf-8', base64=True):
    
    if isinstance(data, six.text_type):
        data = data.encode(charset)
    else:
        charset = None
    if base64:
        data = utils.text(b64encode(data))
    else:
        data = utils.text(quote(data))

    result = ['data:', ]
    if mime_type:
        result.append(mime_type)
    if charset:
        result.append(';charset=')
        result.append(charset)
    if base64:
        result.append(';base64')
    result.append(',')
    result.append(data)

    return ''.join(result)
299912
@Override
    public String encodeURL(ServletRequest request, String uri, SessionAffinityContext affinityContext) {
        return encodeURL(null, request, uri, affinityContext);
    }
1147706
def _encode_request(self, request):
        """"""
        obj = request_to_dict(request, self.spider)
        return self.serializer.dumps(obj)
943017
def encode1(self):
        """"""
        data_uri = b64encode(open(self.path, 'rb').read()).decode('utf-8').replace('\n', '')
        return '<img src="data:image/png;base64,{0}">'.format(data_uri)
689796
function UrlNode(data){
    this.append = function(next){
        this.next = next;
    };
    this.getData = function(){
        return this.data;
    };
    this.setData = function(data){
        this.data = data;
    }
    this.getNext = function(){
        return this.next;
    };
    this.setParams = function(params){
        var queryParameters = params.split("&");
        if(queryParameters != null){
            this.params = [];
            for(var counter = 0; counter < queryParameters.length; counter++) {
                var keyValuePair = queryParameters[counter].split("=");
                this.params[keyValuePair[0]] = keyValuePair[1];
            }
        } else{
            queryParameters = null;
        }
    };
    this.getParams = function(){
        return this.params;
    };

    //set var's for this object
    var queryParamSplit = data.split("?");
    this.params = null;
    this.data = null;
    this.next = null;
    if(queryParamSplit != null && queryParamSplit.length > 1){
        this.setData(queryParamSplit[0]);
        this.setParams(queryParamSplit[1]);
    } else{
        this.setData(data);
    }
}
332018
function encode(data) {
	const bytes = buffer.Buffer.from(data, 'utf8');
	const pixelData = prependLength(bytes);

	return createPng(pixelData);
}
933072
static String encodeURLString(String stringToEncode) {
        try {
            return java.net.URLEncoder.encode(stringToEncode, "UTF-8").replace("+", ENCODED_SPACE_CHARACTER);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e); // can't happen
        }
    }
1255940
public String encodeURL(HttpSession session, String url) {
        return encodeURL(session, null, url, null);
    }
1231079
private void encodePair(StringBuffer result, String name, Object value, boolean first) {
    if (!first)
      result.append('&');
    URLEncode(result, name);
    result.append('=');
    encodeObject(result, value);
  }
630737
function encodeProblemUrlChars(url) {
            if (!url)
                return "";

            var len = url.length;

            return url.replace(_problemUrlChars, function (match, offset) {
                if (match == "~D") // escape for dollar
                    return "%24";
                if (match == ":") {
                    if (offset == len - 1 || /[0-9\/]/.test(url.charAt(offset + 1)))
                        return ":"
                }
                return "%" + match.charCodeAt(0).toString(16);
            });
        }
306998
def to_postdata(self):
        """"""
        items = []
        for k, v in sorted(self.items()):  # predictable for testing
            items.append((k.encode('utf-8'), to_utf8_optional_iterator(v)))

        # tell urlencode to deal with sequence values and map them correctly
        # to resulting querystring. for example self["k"] = ["v1", "v2"] will
        # result in 'k=v1&k=v2' and not k=%5B%27v1%27%2C+%27v2%27%5D
        return urlencode(items, True).replace('+', '%20').encode('ascii')
640465
def encode(data):
    
    res = ""
    for i in range(0,len(data), 3):
        if (i+2==len(data)):
            res += _encode3bytes(ord(data[i]), ord(data[i+1]), 0)
        elif (i+1==len(data)):
            res += _encode3bytes(ord(data[i]), 0, 0)
        else:
            res += _encode3bytes(ord(data[i]), ord(data[i+1]), ord(data[i+2]))
    return res
69798
function encodeQueryData(obj, prefix) {
          var str = [];
          for (var p in obj) {
            if (obj.hasOwnProperty(p)) {
              var k = prefix ? prefix + '[' + p + ']' : p, v = obj[p];
              str.push(typeof v === 'object' ? encodeQueryData(v, k) : encodeURIComponent(k) + '=' + encodeURIComponent(v));
            }
          }
          return str.join('&');
        }
1195100
public static String getData(String dataUrl) {
        int indexOfComma = dataUrl.indexOf(',');
        return dataUrl.substring(indexOfComma + 1);
    }
1131456
function encode(data) {
  $.checkArgument(data instanceof Array, 'Must be Array');
  var base32 = '';
  for (var i=0; i<data.length; i++) {
    var value = data[i];
    $.checkArgument(0 <= value && value < 32, 'Non-base32, value ' + value);
    base32 += CHARSET[value];
  }
  return base32;
}
933820
def data_url(content, mimetype=None):
    
    if isinstance(content, pathlib.Path):
        if not mimetype:
            mimetype = guess_type(content.name)[0]
        with content.open('rb') as fp:
            content = fp.read()
    else:
        if isinstance(content, text_type):
            content = content.encode('utf8')
    return "data:{0};base64,{1}".format(
        mimetype or 'application/octet-stream', b64encode(content).decode())
951396
function encodeParams(params) {
    var queryString;
    if (params && Object.keys(params)) {
        queryString = [].slice.call(arguments).reduce(function (a, b) {
            return a.concat(b instanceof Array ? b : [b]);
        }, []).filter(function (c) {
            return "object" === typeof c;
        }).reduce(function (p, c) {
            !(c instanceof Array) ? p = p.concat(Object.keys(c).map(function (key) {
                return [key, c[key]];
            })) : p.push(c);
            return p;
        }, []).reduce(function (p, c) {
            c.length === 2 ? p.push(c) : p = p.concat(c);
            return p;
        }, []).reduce(function (p, c) {
            c[1] instanceof Array ? c[1].forEach(function (v) {
                p.push([c[0], v]);
            }) : p.push(c);
            return p;
        }, []).map(function (c) {
            c[1] = encodeURIComponent(c[1]);
            return c.join("=");
        }).join("&");
    }
    return queryString;
}