carta
mblen(3)

mblen3

Get number of bytes in a character

Usage

int

Library

Standard C Library (libc, -lc)

Overview

The mblen() function computes the length in bytes of a multibyte character mbchar according to the current conversion state. Up to nbytes bytes are examined.

A call with a null mbchar pointer returns nonzero if the current locale requires shift states, zero otherwise; if shift states are required, the shift state is reset to the initial state.

Return values

If mbchar is NULL, the mblen() function returns nonzero if shift states are supported, zero otherwise.

Otherwise, if mbchar is not a null pointer, mblen() either returns 0 if mbchar represents the null wide character, or returns the number of bytes processed in mbchar, or returns -1 if no multibyte character could be recognized or converted. In this case, mblen(Ns, 's) internal conversion state is undefined.

Errors

The mblen() function will fail if:

[EILSEQ]

An invalid multibyte sequence was detected.

[EINVAL]

The internal conversion state is not valid.

History

  • FreeBSD 16.0-CURRENT (2026-10-27) to FreeBSD 15.0-RELEASE: the text shown here
  • FreeBSD 14.5-RELEASE to FreeBSD 13.3-RELEASE
  • FreeBSD 13.2-RELEASE to FreeBSD 13.0-RELEASE
  • FreeBSD 12.4-RELEASE
  • FreeBSD 12.3-RELEASE
  • FreeBSD 12.2-RELEASE
  • FreeBSD 12.1-RELEASE
  • FreeBSD 12.0-RELEASE
  • FreeBSD 11.4-RELEASE
  • FreeBSD 11.3-RELEASE
  • FreeBSD 11.2-RELEASE
  • FreeBSD 11.1-RELEASE
  • FreeBSD 11.0-RELEASE
  • FreeBSD 10.4-RELEASE
  • FreeBSD 10.3-RELEASE
  • FreeBSD 10.2-RELEASE
  • FreeBSD 10.1-RELEASE
  • FreeBSD 10.0-RELEASE
  • FreeBSD 9.3-RELEASE
  • FreeBSD 9.2-RELEASE
  • FreeBSD 9.1-RELEASE
  • FreeBSD 9.0-RELEASE
  • FreeBSD 8.4-RELEASE
  • FreeBSD 8.3-RELEASE
  • FreeBSD 8.2-RELEASE
  • FreeBSD 8.1-RELEASE
  • FreeBSD 8.0-RELEASE
  • FreeBSD 7.4-RELEASE
  • FreeBSD 7.3-RELEASE
  • FreeBSD 7.2-RELEASE
  • FreeBSD 7.1-RELEASE
  • FreeBSD 7.0-RELEASE
  • FreeBSD 6.4-RELEASE
  • FreeBSD 6.3-RELEASE to FreeBSD 5.3-RELEASE
  • FreeBSD 5.2.1-RELEASE to FreeBSD 5.2-RELEASE
  • FreeBSD 5.1-RELEASE
  • FreeBSD 5.0-RELEASE
  • FreeBSD 4.11-RELEASE to FreeBSD 4.5-RELEASE
  • FreeBSD 4.4-RELEASE
  • FreeBSD 4.3-RELEASE
  • FreeBSD 4.2-RELEASE to FreeBSD 4.1-RELEASE
  • FreeBSD 4.0-RELEASE
  • FreeBSD 3.5.1-RELEASE to FreeBSD 3.5-RELEASE
  • FreeBSD 3.4-RELEASE to FreeBSD 2.2.5-RELEASE
  • FreeBSD 2.2.2-RELEASE

Standards

The mblen() function conforms to ISO/IEC 9899:1999 (“ISO C99”).

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.