summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-10-03 08:49:29 +0000
committertjr <tjr@FreeBSD.org>2002-10-03 08:49:29 +0000
commitf18ee8bb402e5cff7b3513c0e7390020b7b09945 (patch)
tree840b3f47ff031e1fba2892acb68af4d0566c766c /lib/libc/locale
parenteba16f8d014702d2cbb7fc47feee765e344015fb (diff)
downloadFreeBSD-src-f18ee8bb402e5cff7b3513c0e7390020b7b09945.zip
FreeBSD-src-f18ee8bb402e5cff7b3513c0e7390020b7b09945.tar.gz
Add an Examples section with an example of how to use the functions.
Diffstat (limited to 'lib/libc/locale')
-rw-r--r--lib/libc/locale/wctrans.316
-rw-r--r--lib/libc/locale/wctype.316
-rw-r--r--lib/libc/locale/wcwidth.325
3 files changed, 54 insertions, 3 deletions
diff --git a/lib/libc/locale/wctrans.3 b/lib/libc/locale/wctrans.3
index 5f491a6..0941e80 100644
--- a/lib/libc/locale/wctrans.3
+++ b/lib/libc/locale/wctrans.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 4, 2002
+.Dd October 3, 2002
.Dt WCTRANS 3
.Os
.Sh NAME
@@ -71,6 +71,20 @@ The
function returns non-zero if successful, otherwise it returns zero
and sets
.Va errno .
+.Sh EXAMPLES
+Reimplement
+.Fn towupper
+in terms of
+.Fn towctrans
+and
+.Fn wctrans :
+.Bd -literal -offset indent
+wint_t
+mytowupper(wint_t wc)
+{
+ return (towctrans(wc, wctrans("toupper")));
+}
+.Ed
.Sh ERRORS
The
.Fn towctrans
diff --git a/lib/libc/locale/wctype.3 b/lib/libc/locale/wctype.3
index f23745b..7843af7 100644
--- a/lib/libc/locale/wctype.3
+++ b/lib/libc/locale/wctype.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 3, 2002
+.Dd October 3, 2002
.Dt WCTYPE 3
.Os
.Sh NAME
@@ -80,6 +80,20 @@ is invalid, otherwise it returns a value of type
.Vt wctype_t
that can be used in subsequent calls to
.Fn iswctype .
+.Sh EXAMPLES
+Reimplement
+.Fn iswalpha
+in terms of
+.Fn iswctype
+and
+.Fn wctype :
+.Bd -literal -offset indent
+int
+myiswalpha(wint_t wc)
+{
+ return (iswctype(wc, wctype("alpha")));
+}
+.Ed
.Sh SEE ALSO
.Xr ctype 3
.Sh STANDARDS
diff --git a/lib/libc/locale/wcwidth.3 b/lib/libc/locale/wcwidth.3
index b651368..78c969e 100644
--- a/lib/libc/locale/wcwidth.3
+++ b/lib/libc/locale/wcwidth.3
@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd August 18, 2002
+.Dd October 3, 2002
.Dt WCWIDTH 3
.Os
.Sh NAME
@@ -52,6 +52,29 @@ argument is a null wide character (L'\e0'),
is not printable,
otherwise it returns the number of column positions the
character occupies.
+.Sh EXAMPLES
+This code fragment reads text from standard input and
+breaks lines that are more than 20 column positions wide,
+similar to the
+.Xr fold 1
+utility:
+.Bd -literal -offset indent
+wint_t ch;
+int column, w;
+
+column = 0;
+while ((ch = getwchar()) != WEOF) {
+ if ((w = wcwidth(ch)) > 0)
+ column += w;
+ if (column >= 20) {
+ putwchar(L'\n');
+ column = 0;
+ }
+ putwchar(ch);
+ if (ch == L'\n')
+ column = 0;
+}
+.Ed
.Sh SEE ALSO
.Xr iswprint 3 ,
.Xr wcswidth 3
OpenPOWER on IntegriCloud