size_t wcsnlen(const wchar_t *s, size_t n);
this returns the length of the wide string pointed to by s, up to a maximum of n wide characters. wcsnlen only examines the first n wide characters of the string s.
wcsnlen is an extension commonly found in Linux and BSD C libraries.