summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/utf8replace_c.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-08 22:37:06 +0200
committerGitHub <[email protected]>2023-04-08 22:37:06 +0200
commit43120f2863a67db416ec3b379eb820e2704cafb7 (patch)
treef3b9917940f94c1582bc39ea6f56b735295ec861 /misc/examples/utf8replace_c.c
parente8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff)
parent6426ac05eb8c4dc1ab22aae2eb4139f9671981b7 (diff)
downloadSTC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.tar.gz
STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.zip
Merge pull request #53 from tylov/dev42
Version 4.2 RC
Diffstat (limited to 'misc/examples/utf8replace_c.c')
-rw-r--r--misc/examples/utf8replace_c.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/misc/examples/utf8replace_c.c b/misc/examples/utf8replace_c.c
index b697efd8..3cde8701 100644
--- a/misc/examples/utf8replace_c.c
+++ b/misc/examples/utf8replace_c.c
@@ -2,24 +2,23 @@
int main()
{
- c_auto (cstr, hello, str)
- {
- hello = cstr_lit("hell😀 w😀rld");
- printf("%s\n", cstr_str(&hello));
+ cstr 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("🐨")
- );
- 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("🐨")
+ );
+ printf("%s\n", cstr_str(&hello));
- c_foreach (c, cstr, hello)
- printf("%.*s,", c_SV(c.u8.chr));
-
- str = cstr_lit("scooby, dooby doo");
- cstr_replace(&str, "oo", "00");
- printf("\n%s\n", cstr_str(&str));
- }
+ c_foreach (c, cstr, hello)
+ printf("%.*s,", c_SV(c.u8.chr));
+
+ cstr str = cstr_lit("scooby, dooby doo");
+ cstr_replace(&str, "oo", "00");
+ printf("\n%s\n", cstr_str(&str));
+
+ c_drop(cstr, &hello, &str);
}