Вопрос

Porting a C application from AIX to Linux - does anyone know if there's an equivalent of the mbsinvalid() function on Linux?

From the AIX pages:

"The mbsinvalid subroutine examines the string pointed to by the S parameter to determine the validity of characters. The LC_CTYPE category affects the behavior of the mbsinvalid subroutine."

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mbsinvalid.htm

Thanks!

Это было полезно?

Решение

Use mbstowcs with NULL destination pointer:

If dest is NULL, n is ignored, and the conversion proceeds as above, except that the converted wide characters are not written out to memory, and that no length limit exists.

....

  1. An invalid multibyte sequence has been encountered. In this case (size_t) -1 is returned.

(from mbstowcs man page).

That is, the result of (size_t)-1 means there was an invalid multibyte sequence.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top