Module: encoding.html

Source: ./encoding/html.reef


Overview

encoding/html - HTML entity encoding and decoding

Provides functions to encode special characters to HTML entities and decode HTML entities back to characters.

Usage: import encoding.html let safe = html_encode("alert('XSS')") // Result: "<script>alert('XSS')</script>"


Functions

fn append_char(s: string, c: char): string

fn substring(s: string, start: int, len: int): string

fn str_equals(s1: string, s2: string): bool

fn is_digit(c: char): bool

fn is_alpha(c: char): bool

fn needs_encoding(c: char): bool

Check if character needs HTML encoding

fn char_to_entity(c: char): string

Convert character to its HTML entity name (if one exists)

fn int_to_char(n: int): char

Helper to convert int to char

fn char_to_int(c: char): int

Helper to convert char to int

fn entity_to_char(entity: string): char

Convert named entity to character Returns 0 (null char) if not recognized

fn html_encode_char(c: char): string

Encode a single character to HTML entity if needed

fn html_encode(s: string): string

Encode special HTML characters: < > & " '

fn html_encode_all(s: string): string

Encode all non-ASCII characters as numeric entities

fn parse_numeric_entity(s: string, pos: int, out_pos: [int]): char

Parse numeric entity ({ or {)

fn parse_named_entity(s: string, pos: int, out_pos: [int]): char

Parse named entity (&)

fn html_decode(s: string): string

Decode HTML entities back to characters


Generated by reefc doc