android ndk不支持宽字符转换

sizeof(whar_t) = 4

用mbstowcs转换后结果不对,看了下android 源码

size_t mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps)
{
const char* s = *src;
const char* s2 = memchr( s, 0, len );

if (s2 != NULL)
len = (size_t)(s2 - s) + 1U;

if (dst)
memcpy( (char*)dst, s, len );

*src = s + len;
return len;
}

size_t mbstowcs(wchar_t *dst, const char *src, size_t len)
{
return mbsrtowcs(dst, &src, len, NULL);
}

 

坑爹呢这是,全按照char* 拷贝,结果当然不对了。

 

网上找了个源码:

http://www.raspberryginger.com/jbailey/minix/html/mbstowcs_8c-source.html

你可能感兴趣的:(android NDK)