amber/web/text_encoder

Types

Allows you to convert a string into binary data (in the form of a Uint8Array) given the encoding.

Examples

import amber/web/text_encoder

text_encoder.new()
|> text_encoder.encode("Hello")
// -> //js(Uint8Array { "0": 72, "1": 101, "2": 108, "3": 108, "4": 111 })
pub type TextEncoder

Functions

pub fn encode(encoder: TextEncoder, input: String) -> Uint8Array

Turns a string into binary data (in the form of a Uint8Array) using UTF-8 encoding.

pub fn encode_into(
  encoder: TextEncoder,
  input: String,
  dest: Uint8Array,
) -> EncodeIntoResult

Encodes a string into the destination Uint8Array and returns the result of the encoding.

pub fn new() -> TextEncoder
Search Document