10d5acd74SJohn Marino.\" Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved. 20d5acd74SJohn Marino.\" Copyright (c) 1993 30d5acd74SJohn Marino.\" The Regents of the University of California. All rights reserved. 4eee2ef09SJoerg Sonnenberger.\" 50d5acd74SJohn Marino.\" This code is derived from software contributed to Berkeley by 60d5acd74SJohn Marino.\" Donn Seeley of BSDI. 7eee2ef09SJoerg Sonnenberger.\" 8eee2ef09SJoerg Sonnenberger.\" Redistribution and use in source and binary forms, with or without 9eee2ef09SJoerg Sonnenberger.\" modification, are permitted provided that the following conditions 10eee2ef09SJoerg Sonnenberger.\" are met: 11eee2ef09SJoerg Sonnenberger.\" 1. Redistributions of source code must retain the above copyright 12eee2ef09SJoerg Sonnenberger.\" notice, this list of conditions and the following disclaimer. 13eee2ef09SJoerg Sonnenberger.\" 2. Redistributions in binary form must reproduce the above copyright 14eee2ef09SJoerg Sonnenberger.\" notice, this list of conditions and the following disclaimer in the 15eee2ef09SJoerg Sonnenberger.\" documentation and/or other materials provided with the distribution. 16*c66c7e2fSzrj.\" 3. Neither the name of the University nor the names of its contributors 170d5acd74SJohn Marino.\" may be used to endorse or promote products derived from this software 180d5acd74SJohn Marino.\" without specific prior written permission. 19eee2ef09SJoerg Sonnenberger.\" 200d5acd74SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21eee2ef09SJoerg Sonnenberger.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22eee2ef09SJoerg Sonnenberger.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 230d5acd74SJohn Marino.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24eee2ef09SJoerg Sonnenberger.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25eee2ef09SJoerg Sonnenberger.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26eee2ef09SJoerg Sonnenberger.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27eee2ef09SJoerg Sonnenberger.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28eee2ef09SJoerg Sonnenberger.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29eee2ef09SJoerg Sonnenberger.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30eee2ef09SJoerg Sonnenberger.\" SUCH DAMAGE. 31eee2ef09SJoerg Sonnenberger.\" 320d5acd74SJohn Marino.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93 330d5acd74SJohn Marino.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp 340d5acd74SJohn Marino.\" $FreeBSD: head/lib/libc/locale/mblen.3 165903 2007-01-09 00:28:16Z imp $ 350d5acd74SJohn Marino.\" 363623cebdSSascha Wildner.Dd December 26, 2013 37eee2ef09SJoerg Sonnenberger.Dt MBLEN 3 38eee2ef09SJoerg Sonnenberger.Os 39eee2ef09SJoerg Sonnenberger.Sh NAME 403623cebdSSascha Wildner.Nm mblen , 413623cebdSSascha Wildner.Nm mblen_l 420d5acd74SJohn Marino.Nd get number of bytes in a character 43eee2ef09SJoerg Sonnenberger.Sh LIBRARY 44eee2ef09SJoerg Sonnenberger.Lb libc 45eee2ef09SJoerg Sonnenberger.Sh SYNOPSIS 46eee2ef09SJoerg Sonnenberger.In stdlib.h 47eee2ef09SJoerg Sonnenberger.Ft int 480d5acd74SJohn Marino.Fn mblen "const char *mbchar" "size_t nbytes" 493623cebdSSascha Wildner.In xlocale.h 503623cebdSSascha Wildner.Ft int 513623cebdSSascha Wildner.Fn mblen_l "const char *mbchar" "size_t nbytes" "locale_t locale" 52eee2ef09SJoerg Sonnenberger.Sh DESCRIPTION 53eee2ef09SJoerg SonnenbergerThe 54eee2ef09SJoerg Sonnenberger.Fn mblen 553623cebdSSascha Wildnerand 563623cebdSSascha Wildner.Fn mblen_l 573623cebdSSascha Wildnerfunctions compute the length in bytes 580d5acd74SJohn Marinoof a multibyte character 590d5acd74SJohn Marino.Fa mbchar 603623cebdSSascha Wildneraccording to a conversion state. 610d5acd74SJohn MarinoUp to 620d5acd74SJohn Marino.Fa nbytes 630d5acd74SJohn Marinobytes are examined. 64eee2ef09SJoerg Sonnenberger.Pp 650d5acd74SJohn MarinoA call with a null 660d5acd74SJohn Marino.Fa mbchar 673623cebdSSascha Wildnerpointer returns nonzero if the locale requires shift states, 680d5acd74SJohn Marinozero otherwise; 690d5acd74SJohn Marinoif shift states are required, the shift state is reset to the initial state. 703623cebdSSascha Wildner.Pp 713623cebdSSascha WildnerThe 723623cebdSSascha Wildner.Fn mblen_l 733623cebdSSascha Wildnerfunction takes an explicit 743623cebdSSascha Wildner.Fa locale 753623cebdSSascha Wildnerargument, whereas the 763623cebdSSascha Wildner.Fn mblen 773623cebdSSascha Wildnerfunction uses the current global or per-thread locale. 78eee2ef09SJoerg Sonnenberger.Sh RETURN VALUES 790d5acd74SJohn MarinoIf 800d5acd74SJohn Marino.Fa mbchar 810d5acd74SJohn Marinois 82eee2ef09SJoerg Sonnenberger.Dv NULL , 83eee2ef09SJoerg Sonnenbergerthe 84eee2ef09SJoerg Sonnenberger.Fn mblen 853623cebdSSascha Wildnerand 863623cebdSSascha Wildner.Fn mblen_l 873623cebdSSascha Wildnerfunctions return nonzero if shift states are supported, 880d5acd74SJohn Marinozero otherwise. 890d5acd74SJohn Marino.Pp 900d5acd74SJohn MarinoOtherwise, if 910d5acd74SJohn Marino.Fa mbchar 920d5acd74SJohn Marinois not a null pointer, 93eee2ef09SJoerg Sonnenberger.Fn mblen 943623cebdSSascha Wildnerand 953623cebdSSascha Wildner.Fn mblen_l 963623cebdSSascha Wildnereither return 0 if 970d5acd74SJohn Marino.Fa mbchar 983623cebdSSascha Wildnerrepresents the null wide character, or return 990d5acd74SJohn Marinothe number of bytes processed in 1000d5acd74SJohn Marino.Fa mbchar , 1013623cebdSSascha Wildneror return \-1 if no multibyte character 1020d5acd74SJohn Marinocould be recognized or converted. 1030d5acd74SJohn MarinoIn this case, 1040d5acd74SJohn Marino.Fn mblen Ns 's 1053623cebdSSascha Wildnerand 1063623cebdSSascha Wildner.Fn mblen_l Ns 's 1073623cebdSSascha Wildnerinternal conversion states are undefined. 1080d5acd74SJohn Marino.Sh ERRORS 1090d5acd74SJohn MarinoThe 1100d5acd74SJohn Marino.Fn mblen 1113623cebdSSascha Wildnerand 1123623cebdSSascha Wildner.Fn mblen_l 1133623cebdSSascha Wildnerfunctions will fail if: 114eee2ef09SJoerg Sonnenberger.Bl -tag -width Er 115eee2ef09SJoerg Sonnenberger.It Bq Er EILSEQ 1160d5acd74SJohn MarinoAn invalid multibyte sequence was detected. 1170d5acd74SJohn Marino.It Bq Er EINVAL 1180d5acd74SJohn MarinoThe internal conversion state is not valid. 119eee2ef09SJoerg Sonnenberger.El 120eee2ef09SJoerg Sonnenberger.Sh SEE ALSO 121eee2ef09SJoerg Sonnenberger.Xr mbrlen 3 , 122eee2ef09SJoerg Sonnenberger.Xr mbtowc 3 , 1233623cebdSSascha Wildner.Xr multibyte 3 , 1243623cebdSSascha Wildner.Xr xlocale 3 125eee2ef09SJoerg Sonnenberger.Sh STANDARDS 126eee2ef09SJoerg SonnenbergerThe 127eee2ef09SJoerg Sonnenberger.Fn mblen 128eee2ef09SJoerg Sonnenbergerfunction conforms to 1290d5acd74SJohn Marino.St -isoC-99 . 130