Files
fx/test/ds/unicode-strings.c

28 lines
715 B
C
Raw Permalink Normal View History

2026-03-16 10:35:43 +00:00
#include <fx/core/stringstream.h>
#include <fx/ds/string.h>
2025-09-22 10:55:20 +01:00
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("здравс\u26A0твуите\n");
2026-03-16 10:35:43 +00:00
fx_string *str = fx_string_create_from_cstr("здравствуите");
const char *s = fx_string_ptr(str);
2025-09-22 10:55:20 +01:00
printf("%s\n", s);
2026-03-16 10:35:43 +00:00
printf("len: %zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL));
printf("codepoints: %zu\n", fx_string_get_size(str, FX_STRLEN_CODEPOINTS));
2025-09-22 10:55:20 +01:00
const char *delims[] = {"в"};
size_t nr_delims = sizeof delims / sizeof delims[0];
2026-03-16 10:35:43 +00:00
fx_iterator *it = fx_string_tokenise(str, delims, nr_delims, 0);
fx_foreach(const char *, tok, it)
2025-11-01 10:04:41 +00:00
{
printf("%s\n", tok);
2025-09-22 10:55:20 +01:00
}
2026-03-16 10:35:43 +00:00
fx_iterator_unref(it);
fx_string_unref(str);
2025-09-22 10:55:20 +01:00
return 0;
}