Commit Graph

14 Commits

Author SHA1 Message Date
d9041cda3f object: to_string() now takes a const object pointer 2025-09-22 10:47:33 +01:00
2fcadf7f39 core: string: add UTF-8 and null-char support; and some new string functions
b_string now uses UTF-8 internally, and can correctly manipulate strings
that contain non-ASCII and multi-byte codepoints.

b_string now tracks the length of a string in both bytes and unicode codepoints.

string insertion functions have been updated to correctly handle strings with
multi-byte codepoints, so the index parameter of each function now refers to codepoints
rather than bytes. inserting single-byte chars into a string with no multi-byte codepoints
is still optimised to used array indexing and memmove.

a b_string_iterator has been added to simplify iterating through a UTF-8 string, without
having to use a charAt()-style interface that would incur performance penalties.

strings can now also contain null bytes.

new functions include:
  - b_string_tokenise: a b_iterator interface for iterating through tokens
    in a string. similar to strtok except that:
    * it is re-entrant, and uses no global state.
    * it supports delimiters that are longer than one character and/or contain
      multi-byte UTF-8 codepoints.
    * it doesn't modify the string that is being iterated over.
    * it correctly handles strings with multi-byte UTF-8 codepoints and null chars.
  - b_string_compare: for comparing strings. necessary to use this rather than strcpy
    as b_strings can now contain null chars.
2025-09-22 10:36:26 +01:00
15ae12aa2e object: string: add b_string_duplicate() 2025-07-28 22:17:48 +01:00
4690738af1 object: add a range of string transformation functions 2025-07-17 17:55:13 +01:00
1c880f5b7d object: string: add missing static qualifier to stream callbacks 2025-06-27 22:06:10 +01:00
c54d51d381 object: update to_string callback to use b_stream instead of b_stringstream 2025-06-27 21:47:55 +01:00
640bf57b60 object: add b_string_substr 2025-04-11 13:55:36 +01:00
4c3cc27d08 object: string: add front, back, and pop_back functions 2025-02-10 21:15:48 +00:00
9add587ddd object: unify stringstream functionality 2025-02-10 13:59:06 +00:00
dfa817cb9a object: string: add b_string_replace_all() 2024-11-18 09:55:46 +00:00
2531f00b81 object: string: fix b_string_steal resetting capacity to wrong value 2024-11-17 09:22:39 +00:00
b2c9c7cab9 object: b_strlen and b_string_get_size can now ignore term's formatting codes 2024-11-14 22:03:09 +00:00
d614e110df add win32 (msvc) support 2024-11-14 16:56:18 +00:00
fa6ebe6a84 add object module from corelib 2024-10-24 19:24:54 +01:00