uformat

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package uformat provides pure rune→string formatting helpers for Unicode byte representations. All functions are stateless and have no side effects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Codepoint added in v0.10.1

func Codepoint(r rune) string

Codepoint returns the Unicode codepoint notation for r, e.g. "U+0041" or "U+1F600". Uses a minimum of four uppercase hex digits.

func HexUpper added in v0.10.1

func HexUpper(r rune) string

HexUpper returns the minimum-width uppercase hex representation of r. For example, "41" for 'A', "1F600" for '😀'.

func JSONEscaped

func JSONEscaped(r rune) string

JSONEscaped returns the JSON/JavaScript escape sequence for r. For characters outside the BMP (r > U+FFFF), returns a UTF-16 surrogate pair \uXXXX\uXXXX. For BMP characters, returns \uXXXX. This mirrors the PRINT_RUNE_JSON logic in resultset.

func RustEscaped

func RustEscaped(r rune) string

RustEscaped returns the Rust Unicode escape sequence for r, using the minimum-length uppercase hex representation without leading zeros. For example, U+2713 → "\\u{2713}", U+1F600 → "\\u{1F600}".

func UTF8Bytes

func UTF8Bytes(r rune) string

UTF8Bytes returns the UTF-8 encoding of r as a space-separated lowercase two-digit hex byte string. For example, U+2713 → "e2 9c 93".

func UTF8Escaped

func UTF8Escaped(r rune) string

UTF8Escaped returns the UTF-8 encoding of r as concatenated \xNN escape sequences, lowercase. For example, U+2713 → "\\xe2\\x9c\\x93".

func UTF8PercentEncoded added in v0.10.1

func UTF8PercentEncoded(r rune) string

UTF8PercentEncoded returns the UTF-8 encoding of r as concatenated percent-encoded bytes, uppercase. For example, U+2713 → "%E2%9C%93". This is the encoding used for non-ASCII bytes in URL percent-encoding.

func UnicodeEscaped

func UnicodeEscaped(r rune) string

UnicodeEscaped returns the Unicode escape sequence for r. For r ≤ U+FFFF, returns \uXXXX (four uppercase hex digits). For r > U+FFFF, returns \UXXXXXXXX (eight uppercase hex digits).

Types

This section is empty.

Jump to

Keyboard shortcuts

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