@technobuddha > library > Binary > Encoding
Function: encodeBase64Url()
Creates a encoded ASCII string from a BinaryObject or string using Base64Url.
You can use this method to encode data which may otherwise cause communication problems, transmit it, then use the decodeBase64Url method to decode the data again. For example, you can encode control characters.
Call Signature
ts
function encodeBase64Url(chars: string, encoding: TextEncoding): string;Defined in: encode-base64-url.ts:19
Convert a string to binary using encodeText with the supplied encoding, and then encode it to Base64Url.
Parameters
| Parameter | Type | Description |
|---|---|---|
chars | string | The string to encode |
encoding | TextEncoding | The encoding of the input string |
Returns
string
An ASCII string containing the Base64Url representation
Example
typescript
encodeBase64Url('Hello, world!', 'utf8'); // "SGVsbG8sIHdvcmxkIQ"Call Signature
ts
function encodeBase64Url(binary: BinaryObject): string;Defined in: src/encode-base64-url.ts:29
Encode a BinaryObject to a Base64Url string.
Parameters
| Parameter | Type | Description |
|---|---|---|
binary | BinaryObject | The Binary object to encode |
Returns
string
An ASCII string containing the Base64Url representation
Example
typescript
encodeBase64Url(new Uint8Array([1, 2, 3])); // "AQID"