1 .\" $NetBSD: mblen.3,v 1.6 2006/10/14 07:51:01 wiz Exp $
3 .\" Copyright (c)2002 Citrus Project,
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" ----------------------------------------------------------------------
33 .Nd get number of bytes in a multibyte character
34 .\" ----------------------------------------------------------------------
37 .\" ----------------------------------------------------------------------
41 .Fn mblen "const char *s" "size_t n"
42 .\" ----------------------------------------------------------------------
46 function usually determines the number of bytes in
47 a multibyte character pointed to by
50 This function shall only examine max n bytes of the array beginning from
53 In state-dependent encodings,
55 may point the special sequence bytes to change the shift-state.
56 Although such sequence bytes corresponds to no individual
60 changes the own state by them and treats them
61 as if they are a part of the subsequent multibyte character.
69 need to form an entire multibyte character.
70 Otherwise, this function causes an error.
73 is equivalent to the following call, except the internal state of the
75 function is not affected:
76 .Bd -literal -offset indent
80 Calling any other functions in
82 never changes the internal
89 category changed to that of the current locale.
92 calls cause the internal state of this function to be indeterminate.
98 category of the current locale.
100 These are the special cases:
101 .Bl -tag -width 0123456789
104 initializes its own internal state to an initial state, and
105 determines whether the current encoding is state-dependent.
106 This function returns 0 if the encoding is state-independent,
112 bytes of the array pointed to by
114 never form a complete character.
119 .\" ----------------------------------------------------------------------
124 .Bl -tag -width 0123456789
130 The value returned is
131 a number of bytes for the valid multibyte character pointed to by
133 There are no cases that this value is greater than
140 points to an invalid or incomplete multibyte character.
145 to indicate the error.
155 .Bl -tag -width 0123456789
157 The current encoding is state-independent.
159 The current encoding is state-dependent.
161 .\" ----------------------------------------------------------------------
164 may cause an error in the following case:
168 points to an invalid or incomplete multibyte character.
170 .\" ----------------------------------------------------------------------
175 .\" ----------------------------------------------------------------------