summaryrefslogtreecommitdiffhomepage
path: root/examples/utf8replace_c.c
blob: 49680ecdff34a55acf2a4435dd6d67ef65f6beab (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", hello.str);

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

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