Decode a url-safe base64-encoded string.

  This returns the decoded string.
325674
def _DecodeUrlSafe(urlsafe):
  
  if not isinstance(urlsafe, basestring):
    raise TypeError('urlsafe must be a string; received %r' % urlsafe)
  if isinstance(urlsafe, unicode):
    urlsafe = urlsafe.encode('utf8')
  mod = len(urlsafe) % 4
  if mod:
    urlsafe += '=' * (4 - mod)
  # This is 3-4x faster than urlsafe_b64decode()
  return base64.b64decode(urlsafe.replace('-', '+').replace('_', '/'))
1229715
def decode_bytes(string):
    

    if is_string_type(type(string)):
        string = bytes(string, "utf-8")
    return base64.decodebytes(string)
618716
def decode_base64_and_inflate(value):
        
        decoded = base64.b64decode(value)
        # We try to inflate
        try:
            result = zlib.decompress(decoded, -15)
        except Exception:
            result = decoded

        return result.decode('utf-8')
1029853
def url_encode(str)
      encoded_string = ""
      str.each_char do |char|
        case char
        when "+"
          encoded_string << "%2b"
        when "="
          encoded_string << "%3d"
        when "?"
          encoded_string << "%3f"
        when "&"
          encoded_string << "%26"
        when "%"
          encoded_string << "%25"
        when ","
          encoded_string << "%2C"
        else
          encoded_string << char
        end
      end
      encoded_string
    end
961549
private static String decodeURL(String url) {
    	try {
			return URLDecoder.decode(url, UTF_8);
		} catch (UnsupportedEncodingException e) {
		}
		return null;
    }
955223
public static String base64Decode(String base64Str,String encoding) throws IOException{
		byte [] rawByte = base64Str.getBytes(encoding);
		return new String(SecureUtil.base64Decode(rawByte),encoding);	
	}
1217626
def makeB64UrlSafe(b64str):
    
    if isinstance(b64str, six.text_type):
        b64str = b64str.encode()
    # see RFC 4648, sec. 5
    return b64str.replace(b'+', b'-').replace(b'/', b'_')
698490
function decode(s) {
    if (s) {
        s = s.toString().replace(re.pluses, '%20');
        s = decodeURIComponent(s);
    }
    return s;
  }
698184
function decode (str) {
  if (!isValid(str)) throw new Error('baseURL#decode: str not valid baseURL string');

  var bits = '';
  // Decode
  for (var i = 0; i < str.length; i++) {
    bits += indexOfBits(str[i]);
  }
  return bits;
}
225612
def base64url_decode(msg):
    
    rem = len(msg) % 4
    if rem:
        msg += b'=' * (4 - rem)

    return base64.urlsafe_b64decode(msg)
896346
private static String decode(final String text)
        throws UnsupportedEncodingException {
        try {
            return URLDecoder.decode(text, Charset.defaultCharset().name());
        } catch (final IllegalArgumentException ex) {
            throw new DecodingException(ex);
        }
    }
700219
def decode(string, base):
    

    base = int(base)
    code_string = get_code_string(base)
    result = 0
    if base == 16:
        string = string.lower()
    while len(string) > 0:
        result *= base
        result += code_string.find(string[0])
        string = string[1:]
    return result
909975
public static function decodeURLSafe($string)
    {
        $remainder = strlen($string) % 4;

        if ($remainder <> 0) {
            $paddingLength = 4 - $remainder;
            $string .= str_repeat('=', $paddingLength);
        }

        return base64_decode(str_replace(array('-', '_'), array('+', '/'), $string));
    }
777451
def decode(self, charset='utf-8', errors='replace'):
        
        return URL(
            self.scheme.decode('ascii'),
            self.decode_netloc(),
            self.path.decode(charset, errors),
            self.query.decode(charset, errors),
            self.fragment.decode(charset, errors)
        )
123765
def decode(data_url):
    
    metadata, data = data_url.rsplit(',', 1)
    _, metadata = metadata.split('data:', 1)
    parts = metadata.split(';')
    if parts[-1] == 'base64':
        data = b64decode(data)
    else:
        data = unquote(data)

    for part in parts:
        if part.startswith("charset="):
            data = data.decode(part[8:])
    return data
442970
private static String decodeUrl(final String url) {
        String decoded = url;
        if (url != null && url.indexOf('%') >= 0) {
            final int n = url.length();
            final StringBuffer buffer = new StringBuffer();
            final ByteBuffer bytes = ByteBuffer.allocate(n);
            for (int i = 0; i < n;) {
                if (url.charAt(i) == '%') {
                    try {
                        do {
                            final byte octet = (byte) Integer.parseInt(url.substring(i + 1, i + 3), 16);
                            bytes.put(octet);
                            i += 3;
                        } while (i < n && url.charAt(i) == '%');
                        continue;
                    } catch (final RuntimeException e) {
                        // malformed percent-encoded octet, fall through and
                        // append characters literally
                    } finally {
                        if (bytes.position() > 0) {
                            bytes.flip();
                            buffer.append(Charsets.UTF_8.decode(bytes).toString());
                            bytes.clear();
                        }
                    }
                }
                buffer.append(url.charAt(i++));
            }
            decoded = buffer.toString();
        }
        return decoded;
    }
1300568
public static byte[] decodeString(String encoded) {
        return encoded == null ? null : Base64.getDecoder().decode(encoded);
    }