source/AccessorySDK/Support/utfconv.c
int
utf8_encodestr_copy( const uint16_t *inUTF16, size_t inUTF16Bytes, 
					 void *outUTF8, size_t *outUTF8Bytes, 
					 uint16_t inAltSlash, int inFlags )
{
	int			err;
	size_t		utf8Bytes;
	uint8_t *	utf8;
	
	utf8Bytes = utf8_encodelen(inUTF16, inUTF16Bytes, inAltSlash, inFlags ) + 1;
	utf8 = (uint8_t *) utfmalloc( utf8Bytes );
	if( !utf8 ) { err = ENOMEM; goto exit; }
	
	err = utf8_encodestr( inUTF16, inUTF16Bytes, utf8, &utf8Bytes, utf8Bytes, inAltSlash, inFlags );
	if( err ) goto exit;
	
	*( (uint8_t **) outUTF8 )			= utf8;
	if( outUTF8Bytes ) *outUTF8Bytes	= utf8Bytes;
	utf8 = NULL;
	
exit:
	if( utf8 ) utffree( utf8 );
	return( err );
}
/*
 * utf8_encodestr_copy - Encodes a UTF-16 string into UTF-8 into a malloc'd buffer.
 *
 * NOTES:
 *    On success, the caller must use utffree to free the UTF-8 buffer when no longer needed.
 *    Otherwise, the same notes as utf8_encodestr.
 *
 * FLAGS:
 *    Same flags as utf8_encodestr.
 *
 * ERRORS:
 *    Same errors as utf8_encodestr.
 */
Encodes a UTF-16 string into UTF-8 into a malloc'd buffer.
NOTES:
On success, the caller must use utffree to free the UTF-8 buffer when no longer needed.
Otherwise, the same notes as utf8_encodestr.

Same flags as utf8_encodestr.

Same errors as utf8_encodestr.
Encodes a UTF - 16 string into UTF - 8 into a malloc ' d buffer . NOTES : On success the caller must use utffree to free the UTF - 8 buffer when no longer needed . Otherwise the same notes as utf8_encodestr . Same flags as utf8_encodestr . Same errors as utf8_encodestr .
int
utf8_encodestr_copy( const uint16_t *inUTF16, size_t inUTF16Bytes, 
					 void *outUTF8, size_t *outUTF8Bytes, 
					 uint16_t inAltSlash, int inFlags )
{
	int			err;
	size_t		utf8Bytes;
	uint8_t *	utf8;
	utf8Bytes = utf8_encodelen(inUTF16, inUTF16Bytes, inAltSlash, inFlags ) + 1;
	utf8 = (uint8_t *) utfmalloc( utf8Bytes );
	if( !utf8 ) { err = ENOMEM; goto exit; }
	err = utf8_encodestr( inUTF16, inUTF16Bytes, utf8, &utf8Bytes, utf8Bytes, inAltSlash, inFlags );
	if( err ) goto exit;
	*( (uint8_t **) outUTF8 )			= utf8;
	if( outUTF8Bytes ) *outUTF8Bytes	= utf8Bytes;
	utf8 = NULL;
exit:
	if( utf8 ) utffree( utf8 );
	return( err );
}
int utf8_encodestr_copy ( const uint16_t * inUTF16 , size_t inUTF16Bytes , void * outUTF8 , size_t * outUTF8Bytes , uint16_t inAltSlash , int inFlags ) { int err ; size_t utf8Bytes ; uint8_t * utf8 ; utf8Bytes = utf8_encodelen ( inUTF16 , inUTF16Bytes , inAltSlash , inFlags ) + 1 ; utf8 = ( uint8_t * ) utfmalloc ( utf8Bytes ) ; if ( ! utf8 ) { err = ENOMEM ; goto exit ; } err = utf8_encodestr ( inUTF16 , inUTF16Bytes , utf8 , & utf8Bytes , utf8Bytes , inAltSlash , inFlags ) ; if ( err ) goto exit ; * ( ( uint8_t * * ) outUTF8 ) = utf8 ; if ( outUTF8Bytes ) * outUTF8Bytes = utf8Bytes ; utf8 = NULL ; exit : if ( utf8 ) utffree ( utf8 ) ; return ( err ) ; }
utf8_encodestr_copy - Encodes a UTF-16 string into UTF-8 into a malloc'd buffer.
utf8_encodestr_copy - Encodes a UTF - 16 string into UTF - 8 into a malloc ' d buffer .