summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/utf8replace_c.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-30 19:26:51 +0100
committerGitHub <[email protected]>2022-12-30 19:26:51 +0100
commit9d59845f622fbb9c225bbe32246a3128ad9ec0b1 (patch)
tree528ebcc735cdb5d958b987c886d369bc02a11320 /misc/examples/utf8replace_c.c
parent5f57d597cd27aef55adbcb3b452973b0c6e33667 (diff)
parente124d8c7377de1dfce45790a196312596f6b9be5 (diff)
downloadSTC-modified-9d59845f622fbb9c225bbe32246a3128ad9ec0b1.tar.gz
STC-modified-9d59845f622fbb9c225bbe32246a3128ad9ec0b1.zip
Merge pull request #41 from tylov/allcaps
Allcaps
Diffstat (limited to 'misc/examples/utf8replace_c.c')
-rw-r--r--misc/examples/utf8replace_c.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/misc/examples/utf8replace_c.c b/misc/examples/utf8replace_c.c
index 22a5c990..2d8d1921 100644
--- a/misc/examples/utf8replace_c.c
+++ b/misc/examples/utf8replace_c.c
@@ -1,23 +1,26 @@
-#define i_extern // add utf8 dependencies
#include <stc/cstr.h>
-#include <stc/csview.h>
int main() {
- c_auto (cstr, hello, upper) {
+ c_AUTO (cstr, hello, str) {
hello = cstr_lit("hell😀 w😀rld");
printf("%s\n", cstr_str(&hello));
/* replace second smiley at utf8 codepoint pos 7 */
- cstr_u8_replace(&hello, cstr_u8_to_pos(&hello, 7), 1, c_SV("🐨"));
+ cstr_u8_replace_at(&hello,
+ cstr_u8_to_pos(&hello, 7),
+ 1,
+ c_SV("🐨")
+ );
printf("%s\n", cstr_str(&hello));
- cstr_replace(&hello, "🐨", "ø", 1);
- printf("%s\n", cstr_str(&hello));
-
- upper = cstr_toupper_sv(cstr_sv(&hello));
-
- c_foreach (c, cstr, hello)
+ c_FOREACH (c, cstr, hello)
printf("%.*s,", c_ARGSV(c.u8.chr));
- puts("");
+
+ //csview sv = c_SV("If you find the time, you will find the winner");
+ //str = cstr_replace_sv(sv, c_SV("find"), c_SV("match"), 0);
+
+ str = cstr_lit("If you find the time, you will find the winner");
+ cstr_replace(&str, "find", "match");
+ printf("\n%s\n", cstr_str(&str));
}
}