FreeBSD/contrib/subversion/subversion/libsvn_subr/utf8proc.c
/* Decode a single UCS-4 code point to UTF-8, appending the result to BUFFER.
 * Assume BUFFER is already filled to *LENGTH and return the new size there.
 * This function does *not* nul-terminate the stringbuf!
 *
 * A returned error indicates that the codepoint is invalid.
 */
Decode a single UCS-4 code point to UTF-8, appending the result to BUFFER.
Assume BUFFER is already filled to *LENGTH and return the new size there.
This function does *not* nul-terminate the stringbuf!

A returned error indicates that the codepoint is invalid.
Decode a single UCS - 4 code point to UTF - 8 appending the result to BUFFER . Assume BUFFER is already filled to * LENGTH and return the new size there . This function does * not * nul - terminate the stringbuf! A returned error indicates that the codepoint is invalid .
static svn_error_t *
encode_ucs4(svn_membuf_t *buffer, apr_int32_t ucs4chr, apr_size_t *length)
{
  apr_size_t utf8len;
  if (buffer->size - *length < 4)
    svn_membuf__resize(buffer, buffer->size + 4);
  utf8len = utf8proc_encode_char(ucs4chr, ((uint8_t*)buffer->data + *length));
  if (!utf8len)
    return svn_error_createf(SVN_ERR_UTF8PROC_ERROR, NULL,
                             _("Invalid Unicode character U+%04lX"),
                             (long)ucs4chr);
  *length += utf8len;
  return SVN_NO_ERROR;
}
static svn_error_t * encode_ucs4 ( svn_membuf_t * buffer , apr_int32_t ucs4chr , apr_size_t * length ) { apr_size_t utf8len ; if ( buffer -> size - * length < 4 ) svn_membuf__resize ( buffer , buffer -> size + 4 ) ; utf8len = utf8proc_encode_char ( ucs4chr , ( ( uint8_t * ) buffer -> data + * length ) ) ; if ( ! utf8len ) return svn_error_createf ( SVN_ERR_UTF8PROC_ERROR , NULL , _ ( " " ) , ( long ) ucs4chr ) ; * length += utf8len ; return SVN_NO_ERROR ; }
Decode a single UCS-4 code point to UTF-8, appending the result to BUFFER.
Decode a single UCS - 4 code point to UTF - 8 appending the result to BUFFER .