ascii

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ascii contains ASCII string/bytes helpers.

They are the helpers HTML parsers use: ASCII whitespace, and case folding of ASCII letters only (unlike strings.EqualFold and strings.ToLower), as the Infra Standard defines them. They work on bytes, which gives the same results as on the code points of UTF-8 text, since the bytes of multi-byte UTF-8 sequences aren't ASCII.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendLower

func AppendLower[S ~string | ~[]byte](dst []byte, s S) []byte

AppendLower appends s to dst with ASCII letters lowercased.

func EqualFold

func EqualFold[A, B ~string | ~[]byte](a A, b B) bool

EqualFold reports whether a and b are equal with ASCII letters compared case-insensitively (an ASCII case-insensitive match), as HTML parsers compare names and keywords (strings.EqualFold also folds other letters, such as U+017F to s).

func IsBlank

func IsBlank[S ~string | ~[]byte](s S) bool

IsBlank reports whether s is empty or contains only ASCII whitespace.

func IsSpace

func IsSpace(c byte) bool

IsSpace reports whether c is ASCII whitespace (space, tab, newline, form feed or carriage return), which HTML uses for whitespace.

func ToLower

func ToLower[S ~string | ~[]byte](s S) S

ToLower returns s with ASCII letters lowercased (the Infra Standard's ASCII lowercase), as HTML parsers lowercase names (other letters are kept). It only allocates if s has uppercase ASCII letters: otherwise, it returns s, which for a []byte is the same slice. It doesn't modify s.

func ToLowerByte

func ToLowerByte(c byte) byte

ToLowerByte returns c lowercased if it is an ASCII letter, or c otherwise.

func TrimSpace

func TrimSpace[S ~string | ~[]byte](s S) S

TrimSpace returns s without leading and trailing ASCII whitespace, like the Infra Standard's strip leading and trailing ASCII whitespace. Unlike strings.TrimSpace, it doesn't remove other whitespace (such as vertical tabs or U+00A0).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL