Returns the key in an encoded form that can be used as part of a URL.
511557
public String toUrlSafe() {
    try {
      return URLEncoder.encode(TextFormat.printToString(toPb()), UTF_8.name());
    } catch (UnsupportedEncodingException e) {
      throw new IllegalStateException("Unexpected encoding exception", e);
    }
  }
959760
def _key_from_json(self, data):
        
        key = Key()
        key.algorithm = data["Algorithm"]
        key.cipher_mode = data["CipherMode"]
        key.expiration = datetime.strptime(data["Expiration"].split(".")[0],
                                           "%Y-%m-%dT%H:%M:%S")
        key.key_id = data["ID"]
        key.key = data["Key"]
        key.size = data["KeySize"]
        key.url = data["KeyUrl"]
        return key
952401
public static String urlDecode(String s) {
		if (s == null) {
			return "";
		}
		String decoded = s;
		try {
			decoded = URLDecoder.decode(s, Config.DEFAULT_ENCODING);
		} catch (UnsupportedEncodingException ex) {
			logger.error(null, ex);
		}
		return decoded;
	}
1311399
private static String decodeUrl(String url) {
        if (url == null) {
            return null;
        }

        try {
            return URLDecoder.decode(url, CHARSET_UTF8);
        } catch (UnsupportedEncodingException e) {
            return url;
        }
    }
432801
private static String getKeyValuePair(final Pair<String,String> param, 
        final boolean formEncoding)
        {
        try 
            {
            return getKeyValuePair(param.getFirst(), param.getSecond(), 
                formEncoding);
            }
        catch (final Exception e)
            {
            LOG.error("Could not get encoding for: {}", param, e);
            return "unknown=unknown";
            }
        }
303684
def from_urlencoded(self, urlencoded, **kwargs):
        

        # parse_qs returns a dictionary with keys and values. The values are
        # always lists even if there is only one value in the list.
        # keys only appears once.

        if isinstance(urlencoded, str):
            pass
        elif isinstance(urlencoded, list):
            urlencoded = urlencoded[0]

        _spec = self.c_param

        _info = parse_qs(urlencoded)
        if len(urlencoded) and _info == {}:
            raise FormatError('Wrong format')

        for key, val in _info.items():
            try:
                (typ, _, _, _deser, null_allowed) = _spec[key]
            except KeyError:
                try:
                    _key, lang = key.split("#")
                    (typ, _, _, _deser, null_allowed) = _spec[_key]
                except (ValueError, KeyError):
                    try:
                        (typ, _, _, _deser, null_allowed) = _spec['*']
                    except KeyError:
                        if len(val) == 1:
                            val = val[0]

                        self._dict[key] = val
                        continue

            if isinstance(typ, list):
                if _deser:
                    self._dict[key] = _deser(val[0], "urlencoded")
                else:
                    self._dict[key] = val
            else:  # must be single value
                if len(val) == 1:
                    if _deser:
                        self._dict[key] = _deser(val[0], "urlencoded")
                    elif isinstance(val[0], typ):
                        self._dict[key] = val[0]
                    else:
                        self._dict[key] = val[0]
                else:
                    raise TooManyValues('{}'.format(key))

        return self
622422
function urlencoded (options) {
  var opts = options || {}

  // notice because option default will flip in next major
  if (opts.extended === undefined) {
    deprecate('undefined extended: provide extended option')
  }

  var extended = opts.extended !== false
  var inflate = opts.inflate !== false
  var limit = typeof opts.limit !== 'number'
    ? bytes.parse(opts.limit || '100kb')
    : opts.limit
  var type = opts.type || 'application/x-www-form-urlencoded'
  var verify = opts.verify || false

  if (verify !== false && typeof verify !== 'function') {
    throw new TypeError('option verify must be function')
  }

  // create the appropriate query parser
  var queryparse = extended
    ? extendedparser(opts)
    : simpleparser(opts)

  // create the appropriate type checking function
  var shouldParse = typeof type !== 'function'
    ? typeChecker(type)
    : type

  function parse (body) {
    return body.length
      ? queryparse(body)
      : {}
  }

  return function urlencodedParser (req, res, next) {
    if (req._body) {
      debug('body already parsed')
      next()
      return
    }

    req.body = req.body || {}

    // skip requests without bodies
    if (!typeis.hasBody(req)) {
      debug('skip empty body')
      next()
      return
    }

    debug('content-type %j', req.headers['content-type'])

    // determine if request should be parsed
    if (!shouldParse(req)) {
      debug('skip parsing')
      next()
      return
    }

    // assert charset
    var charset = getCharset(req) || 'utf-8'
    if (charset !== 'utf-8') {
      debug('invalid charset')
      next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
        charset: charset
      }))
      return
    }

    // read
    read(req, res, next, parse, debug, {
      debug: debug,
      encoding: charset,
      inflate: inflate,
      limit: limit,
      verify: verify
    })
  }
}
1241171
public static String encodedEntry(String bucket, String key) {
        String encodedEntry;
        if (key != null) {
            encodedEntry = UrlSafeBase64.encodeToString(bucket + ":" + key);
        } else {
            encodedEntry = UrlSafeBase64.encodeToString(bucket);
        }
        return encodedEntry;
    }
1050679
private String encodeKeysGet(String keys) {
        try {
            return URLEncoder.encode(keys, "UTF-8");
        } catch(Exception ex) {
            throw new RuntimeException("Could not prepare view argument: " + ex);
        }
    }
1097457
def urlencode(self):
        
        output = ('%s=%s' % (k, quote(v)) for k, v in self.items())
        return '&'.join(output)
1281091
def urlencoded(body, charset='ascii', **kwargs):
    """"""
    return parse_query_string(text(body, charset=charset), False)
460270
def get_captcha_key(self, captcha_image_url):
        """"""

        if self.interactive:
            print('Open CAPTCHA image url in your browser and enter it below: ',
                  captcha_image_url)
            captcha_key = raw_input('Enter CAPTCHA key: ')
            return captcha_key
        else:
            raise VkAuthError(
                'Captcha is required. Use interactive mode to enter it '
                'manually')
740239
def prettykey(self, key):
        
        f = list(self.decodekey(key))
        f[0] = f[0].decode('utf-8')
        if len(f) > 2 and type(f[2]) == bytes:
            f[2] = f[2].decode('utf-8')

        if f[0] == '.':
            if len(f) == 2:
                return "%s%16x" % tuple(f)
            elif len(f) == 3:
                return "%s%16x %s" % tuple(f)
            elif len(f) == 4:
                if f[2] == 'H' and type(f[3]) in (str, bytes):
                    f[3] = f[3].decode('utf-8')
                    return "%s%16x %s '%s'" % tuple(f)
                elif type(f[3]) in (int, long):
                    return "%s%16x %s %x" % tuple(f)
                else:
                    f[3] = hexdump(f[3])
                    return "%s%16x %s %s" % tuple(f)
        elif f[0] in ('N', 'n', '$'):
            if type(f[1]) in (int, long):
                return "%s %x %16x" % tuple(f)
            else:
                return "%s'%s'" % tuple(f)
        elif f[0] == '-':
            return "%s %x" % tuple(f)

        return hexdump(key)
549876
def _urlendecode(url, func):
    
    parsed = urlparse(url)
    for attr in URL_ENCODABLE_PARTS:
        parsed = parsed._replace(**{attr: func(getattr(parsed, attr))})
    return urlunparse(parsed)
1069947
def _form_key_str(path):
    
    if path.endswith('.css'):
        media_path_prefix = msettings['CSS_PATH']
    elif path.endswith('.js'):
        media_path_prefix = msettings['JS_PATH']
    else:
        # This isn't a CSS/JS file, no combo for you.
        return None

    if media_path_prefix:
        # CS/JSS path prefix has been set. Factor that into the key lookup.
        if not media_path_prefix.endswith('/'):
            # We need to add this slash so we can lop it off the 'path'
            # variable, to match the value in the JOINED dict.
            media_path_prefix += '/'

        if path.startswith(media_path_prefix):
            # Given path starts with the CSS/JS media prefix. Lop this off
            # so we can perform a lookup in the JOINED dict.
            return path[len(media_path_prefix):]
        else:
            # Path is in a root dir, send along as-is.
            return path

    # No CSS/JS path prefix set. Keep it raw.
    return path
1100678
public String getEncodedUrl() {
		if (method.equals(HttpMethod.GET)) {
			UrlBuilder builder = new UrlBuilder(url);
			for (String name : getParams().keySet()) {
				builder.addParameter(name, getParams().get(name));
			}
			return builder.toString();
		} else {
			return url;
		}
	}
818302
private String decodeIfEncoded(String value) {
    if (StringUtils.contains(value, "%")) {
      try {
        return URLDecoder.decode(value, CharEncoding.UTF_8);
      }
      catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
      }
    }
    return value;
  }