glentities

Types

pub type EncodeMode {
  Named
  Hex
}

Constructors

  • Named

    Encode all characters that have a specified named entity using that name, except tab and newline.

  • Hex

    Encode all characters using hex entities, except a-z, A-Z, 0-9, newline, tab, carriage return, and space.

Functions

pub fn decode(text: String) -> String

Decode any HTML entities in the given string.

pub fn decode_dec(entity: String) -> String

Decode given entity (without surrounding &# and ;) as decimal entity. Returns original if cannot be decoded.

pub fn decode_hex(entity: String) -> String

Decode given entity (without surrounding &#x and ;) as hex entity. Returns original if cannot be decoded.

pub fn decode_named(entity: String) -> String

Decode given entity (without surrounding & and ;) as a named entity. Returns original if it doesn’t match any entity name.

pub fn encode(text: String, mode: EncodeMode) -> String

Encode characters in text as HTML entities with given encoding mode.

pub fn encode_hex(text: String) -> String

Encode text using HTML hex entities, except a-z, A-Z, 0-9, newline, tab, carriage return, and space.

pub fn encode_named(text: String, acc: StringBuilder) -> String

Encoded text using named HTML entities, except newline and tab. Characters without a named entity are untouched.

Search Document