Hint

Refer to QMK’s documentation for details on how to use community modules

string

Small utilities to work with text.

struct string_t
[source]

“String builder” without heap (malloc(), realloc(), free) usage.

Code using this API would look similar to:

// create a stack-based buffer, 50bytes long
string_t str = str_new(50);
// add text to it
str_append(&str, "Hello");
str_append(&str, " world");
// display it
printf("%.*s\n", str.used, str.ptr);
const size_t size
[source]

Total size in bytes.

size_t used
[source]

How many bytes have been used.

char *ptr
[source]

Text start.

str_new(n)
[source]

Create a temporary string_t.

str_from_buffer(buffer)
[source]

Create a string_t wrapper for the given buffer.

size_t str_available(string_t str)
[source]

Find out how many bytes in the buffer are left to be used.

void str_reset(string_t *str)
[source]

Reset the string’s state.

int str_append(string_t *str, const char *text)
[source]

Add text to the string.

int pretty_bytes(string_t *str, size_t n)
[source]

Write the value of n (# of bytes) in an human-friendly format, into string

bool is_utf8(char chr)
[source]

Check whether a char is UTF8.

bool is_utf8_continuation(char chr)
[source]

Check whether a char is a UTF8-continuation byte.