@technobuddha > library > Binary > Encoding
Function: decodeBase64Url()
Decodes a string of data which has been encoded using Base64Url encoding.
You can use the encodeBase64Url method to encode and transmit data which may otherwise cause communication problems, then transmit it and use the decodeBase64Url method to decode the data again. For example, you can encode, transmit, and decode control characters.
Remarks
Whitespace within the Base64 encoded string is ignored.
Throws
TypeError If the input string is not correctly encoded.
Call Signature
function decodeBase64Url(input: string): Uint8Array;Defined in: decode-base64-url.ts:16
Decode a Base64Url encoded string and output in binary format.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | A string containing the Base64 encoded data to decode. |
Returns
An Uint8Array containing the decoded data.
Example
decodeBase64('SGVsbG8sIHdvcmxkIQ==');
// Uint8Array([72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33])Call Signature
function decodeBase64Url(input: string, encoding: TextEncoding): string;Defined in: src/decode-base64-url.ts:29
Decode a Base64Url encoded string as a string with the specified text encoding.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | A string containing the Base6Url encoded data to decode. |
encoding | TextEncoding | The text encoding to use for the decoded string. |
Returns
string
An string containing the decoded data.
Example
decodeBase64('SGVsbG8sIHdvcmxkIQ==', 'utf-8');
// "Hello, world!"