static size_t ucs2_to_utf8( const uint16_t * ucs2str,
                            size_t           ucs2strsiz,
                            char *           utf8str,
                            size_t           utf8strsiz,
                            uint32_t         flags )
{
    size_t ucs2strlen;
    size_t utf8strlen;

    for ( ucs2strlen = 0; ucs2strlen < ucs2strsiz; ucs2strlen++ )
    {
        if ( ucs2str[ucs2strlen] == 0 )  break;
    }

    utf8_encodestr( ucs2str,
                    ucs2strlen * sizeof(uint16_t),
                    (uint8_t *) utf8str,
                    &utf8strlen,
                    utf8strsiz,
                    '/',
#ifdef __BIG_ENDIAN__
                    (flags & UCS_LITTLE_ENDIAN) ? UTF_REVERSE_ENDIAN : 0 );
#else /* !__BIG_ENDIAN__ */
                    (flags & UCS_LITTLE_ENDIAN) ? 0 : UTF_REVERSE_ENDIAN );
#endif /* !__BIG_ENDIAN__ */

    return utf8strlen;
}
Exemple #2
0
	void SetWindowsPath(char* remotePath)
	{
		CHAR  remotePathA[MAX_PATH], *as = remotePathA;
		WCHAR remotePathW[MAX_PATH], *ws = remotePathW;
		size_t si = sizeof(u_int16_t), so = 0, lo = sizeof(remotePathA);

		MultiByteToWideChar(CP_ACP, 0, remotePath, -1, remotePathW, MAX_PATH);
		// UCS-2 to UTF-8-MAC
		while (*ws && lo > so) {
			utf8_encodestr((const u_int16_t *)ws, si, (u_int8_t *)as, &so, lo -= so, 0, UTF_NO_NULL_TERM | UTF_DECOMPOSED);
			ws += si/2; as += so;
		}
		*as = 0;
		SetString(remotePathA);
		Replace('\\', '/');
	}