diff options
author | pommicket <pommicket@gmail.com> | 2023-09-07 14:06:16 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-07 14:06:16 -0400 |
commit | bb4b7774aabc2686f936935b02899b1aa0bf1f2b (patch) | |
tree | d218d61e8163bf2e7cbdc352ab86744e8f250be8 /util.h | |
parent | 7b8b4d4495164250c71582347dd0338d387c4e98 (diff) |
use LSPString in requests too for consistency
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -259,6 +259,18 @@ String32 str32(char32_t *str, size_t len); String32 str32_substr(String32 s, size_t from, size_t len); void str32_free(String32 *s); String32 str32_from_utf8(const char *utf8); +/// convert UTF-32 to UTF-8. +/// +/// returns false on invalid UTF-32 (and `out` will be truncated to just +/// the prefix of `s` that is valid UTF-32) +/// +/// out buffer must be long enough to fit the UTF-8 representation of `s`! +/// (`s.len * 4 + 1` is a safe buffer size) +bool str32_to_utf8_cstr_in_place(String32 s, char *out); +/// returns a null-terminated UTF-8 string +/// +/// the string returned should be free'd +/// this will return NULL on failure char *str32_to_utf8_cstr(String32 s); int str32_cmp_ascii(String32 s, const char *ascii); bool str32_has_ascii_prefix(String32 s, const char *ascii); |