[hackers] [libgrapheme][PATCH] Add example to man page

From: Ivan Tham <pickfire_AT_riseup.net>
Date: Tue, 31 Mar 2020 17:18:47 +0800

---
 man/grapheme_len.3 | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git man/grapheme_len.3 man/grapheme_len.3
index b7f13b7..90951d0 100644
--- man/grapheme_len.3
+++ man/grapheme_len.3
_AT_@ -12,6 +12,25 @@
 .Nm
 returns the length (in bytes) of the grapheme cluster beginning at
 the provided char-address.
+.Sh EXAMPLES
+.Bd -literal
+/* cc -o example example.c -lgrapheme */
+#include <grapheme.h>
+#include <stdio.h>
+
+int
+main(void)
+{
+	char *s;
+	size_t len;
+
+	for (s = "안, 蠀, ☃\\n"; *s != '\0'; s += len) {
+		len = grapheme_len(s);
+		printf("%2zu bytes | %.*s\\n", len, (int)len, s, len);
+	}
+
+	return 0;
+}
 .Sh SEE ALSO
 .Xr libgrapheme 7
 .Sh AUTHORS
-- 
2.26.0
Received on Tue Mar 31 2020 - 11:18:47 CEST

This archive was generated by hypermail 2.3.0 : Tue Mar 31 2020 - 11:24:36 CEST