将C应用程序从AIX移植到Linux-有人知道Linux上是否有等效的mbsinvalid()函数吗?
从AIX页面:
“ mbsinvalid子例程检查S参数指向的字符串以确定字符的有效性.LC_CTYPE类别影响mbsinvalid子例程的行为.”
谢谢!
解决方法:
将mbstowcs与NULL目标指针一起使用:
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.
….
- An invalid multibyte sequence has been encountered. In this case (size_t) -1 is returned.
(从mbstowcs man page开始).
也就是说,(size_t)-1的结果表示存在无效的多字节序列.