aboutsummaryrefslogtreecommitdiffstats
path: root/man3/libsimple_strisutf8.3
blob: 3eecce6f60423e8547067ed76cb0cddf93b3047a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
.TH LIBSIMPLE_STRISUTF8 3 libsimple
.SH NAME
libsimple_strisutf8, libsimple_strnisutf8, libsimple_memisutf8 \- check if a string is encoded in UTF-8

.SH SYNOPSIS
.nf
#include <libsimple.h>

inline int libsimple_strisutf8(const char *\fIstring\fP, int \fIallow_modified_nul\fP);
inline int libsimple_strnisutf8(const char *\fIstring\fP, size_t \fIn\fP, int \fIallow_modified_nul\fP);
int libsimple_memisutf8(const char *\fIstring\fP, size_t \fIn\fP, int \fIallow_modified_nul\fP);

#ifndef strisutf8
# define strisutf8 libsimple_strisutf8
#endif
#ifndef strnisutf8
# define strnisutf8 libsimple_strnisutf8
#endif
#ifndef memisutf8
# define memisutf8 libsimple_memisutf8
#endif
.fi
.PP
Link with
.IR \-lsimple .

.SH DESCRIPTION
The
.BR libsimple_strisutf8 (),
.BR libsimple_strnisutf8 (),
and
.BR libsimple_memisutf8 ()
functions checks if
.I string
is in valid UTF-8. If
.I allow_modified_nul
is non-zero, NUL encoded with 2 bytes is accepted.
.PP
The
.BR libsimple_strisutf8 ()
function reads
.I string
until the first NUL byte.
.PP
The
.BR libsimple_strnisutf8 ()
function reads
.I string
until the first NUL byte or the first
.I n
bytes, whichever is shorter.
.PP
The
.BR libsimple_memisutf8 ()
function reads the first
.I n
bytes from string
.IR string ,
allowing the checked text to contain NUL bytes.
Note that unlike other
.BR mem *
functions, the
.I string
parameter for the
.BR libsimple_memisutf8 ()
function is a
.B const char *
rather than a
.BR "const void *" .

.SH RETURN VALUE
The
.BR libsimple_strisutf8 (),
.BR libsimple_strnisutf8 (),
and
.BR libsimple_memisutf8 ()
function returns 1 if the
.I string
is in valid UTF-8 (Modified UTF-8 if
.I allow_modified_nul
is non-zero); otherwise 0 is returned.

.SH ERRORS
The
.BR libsimple_strisutf8 (),
.BR libsimple_strnisutf8 (),
and
.BR libsimple_memisutf8 ()
functions cannot fail.

.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lb lb lb
l l l.
Interface	Attribute	Value
T{
.BR libsimple_strisutf8 (),
.br
.BR libsimple_strnisutf8 (),
.br
.BR libsimple_memisutf8 ()
T}	Thread safety	MT-Safe
T{
.BR libsimple_strisutf8 (),
.br
.BR libsimple_strnisutf8 (),
.br
.BR libsimple_memisutf8 ()
T}	Async-signal safety	AS-Safe
T{
.BR libsimple_strisutf8 (),
.br
.BR libsimple_strnisutf8 (),
.br
.BR libsimple_memisutf8 ()
T}	Async-cancel safety	AC-Safe
.TE

.SH EXAMPLES
None.

.SH APPLICATION USAGE
None.

.SH RATIONALE
None.

.SH FUTURE DIRECTIONS
None.

.SH NOTES
None.

.SH BUGS
None.

.SH SEE ALSO,
None.