Operating systems, development tools, and professional services
for connected embedded systems

Developer Resources
Blogs
Board support packages
Foundry27 projects
Forums
Hardware support listing
Online video tutorials
Product documentation

utf8len

utf8len()

Count the bytes in a UTF-8 character

Synopsis:

#include <utf8.h>

int utf8len( const char *s,
             size_t n );

Arguments:

s
A pointer to a UTF-8 character.
n
The maximum number of bytes to count.

Library:

ph

Description:

The utf8str() function counts the number of bytes in the UTF-8 character pointed to by s, to a maximum of n bytes, if n is nonzero.

This function is similar to mblen(), except that:

Returns:

0
s points to the null character.
> 0
The number of bytes that comprise the multibyte character (if the next n or fewer bytes form a valid multibyte character).
-1
The n-byte sequence that s points to isn't a valid (beginning of a) UTF-8-encoded character.
Other negative value
The n bytes pointed to by s could be the initial bytes of a valid UTF-8 sequence.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

utf8strblen(), utf8strlen(), utf8strnlen()

Unicode Multilingual Support in the Photon Programmer's Guide

mblen() in the QNX Neutrino Library Reference