core/unicode/utf8

utf8

Types

4

Constants

26

LOCB

LOCB :: 0b1000_0000Source

The default lowest and highest continuation byte.

Variables

2

accept_sizes

accept_sizes :: [256]u8 = [256]u8{ 0x00..=0x7f = 0xf0, // ascii, size 1 0x80..=0xc1 = 0xf1, // invalid, size 1 0xc2..=0xdf = 0x02, // accept 1, size 2 0xe0 = 0x13, // accept 1, size 3 0xe1..=0xec = 0x03, // accept 0, size 3 0xed = 0x23, // accept 2, size 3 Source

Procedures

38

decode_grapheme_clusters

decode_grapheme_clusters :: proc(str: string, track_graphemes: untyped boolean = true, allocator: mem.Allocator = context.allocator) -> (graphemes: [dynamic]Grapheme, grapheme_count: int, rune_count: int, width: int)Source

Decode the individual graphemes in a UTF-8 string.

Allocates Using Provided Allocator

  • str: The input string.
  • track_graphemes: Whether or not to allocate and return graphemes with extra data about each grapheme.
  • allocator: (default: context.allocator)
  • graphemes: Extra data about each grapheme.
  • grapheme_count: The number of graphemes in the string.
  • rune_count: The number of runes in the string.
  • width: The width of the string in number of monospace cells.

full_rune_in_bytes

full_rune_in_bytes :: proc(b: []u8) -> (bool)Source

full_rune_in_bytes reports if the bytes in b begin with a full utf-8 encoding of a rune or not An invalid encoding is considered a full rune since it will convert as an error rune of width 1 (RUNE_ERROR)

full_rune_in_string

full_rune_in_string :: proc(s: string) -> (bool)Source

full_rune_in_string reports if the bytes in s begin with a full utf-8 encoding of a rune or not An invalid encoding is considered a full rune since it will convert as an error rune of width 1 (RUNE_ERROR)

grapheme_count

grapheme_count :: proc(str: string) -> (graphemes: int, runes: int, width: int)Source

Count the individual graphemes in a UTF-8 string.

  • str: The input string.
  • graphemes: The number of graphemes in the string.
  • runes: The number of runes in the string.
  • width: The width of the string in number of monospace cells.

Procedure Groups

4

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.