summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/utf8replace_c.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-30 12:36:13 +0100
committerTyge Løvset <[email protected]>2022-12-30 14:38:39 +0100
commit4f0f45422fb58e9b134445ad6a4ea96d806214e8 (patch)
treeea0bb95c1f82fa5ec71218ce1f6d7ce9bfcc4e29 /misc/examples/utf8replace_c.c
parent0761c13f316cc98ae7756f3527931aa86bed5016 (diff)
downloadSTC-modified-4f0f45422fb58e9b134445ad6a4ea96d806214e8.tar.gz
STC-modified-4f0f45422fb58e9b134445ad6a4ea96d806214e8.zip
More restructuring of files and cleanup. Moved carr2.h and carr3.h to misc/include/old/ as it is not among classic containers.
Removed stctest.h: Recommending https://github.com/bvdberg/ctest instead.
Diffstat (limited to 'misc/examples/utf8replace_c.c')
-rw-r--r--misc/examples/utf8replace_c.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/misc/examples/utf8replace_c.c b/misc/examples/utf8replace_c.c
index 3645bd0a..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_at(&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_ex(&hello, "🐨", "ø", 1);
- printf("%s\n", cstr_str(&hello));
-
- upper = cstr_toupper_sv(cstr_sv(&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));
}
}