summaryrefslogtreecommitdiffhomepage
path: root/examples/utf8replace_c.c
blob: 6b3fcebe553f5837f30758b144ba2d5b62ed1cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stc/cstr.h>
#include <stc/csview.h>
#include <stc/utf8.h>

int main() {
    c_auto (cstr, hello) {
        hello = cstr_new("hell😀 world");
        printf("%s\n", cstr_str(&hello));

        cstr_replace_sv(
            &hello, 
            utf8_substr(cstr_str(&hello), 4, 1), 
            c_sv("🐨")
        );
        printf("%s\n", cstr_str(&hello));

        csview sv = csview_from_s(&hello);
        c_foreach (c, csview, sv)
            printf("%" c_PRIsv ",", c_ARGsv(c.codep));
    }
}