FreeBSD/contrib/subversion/subversion/libsvn_subr/utf.c
/* Construct an error with code APR_EINVAL and with a suitable message
 * to describe the invalid UTF-8 sequence DATA of length LEN (which
 * may have embedded NULLs).  We can't simply print the data, almost
 * by definition we don't really know how it is encoded.
 */
Construct an error with code APR_EINVAL and with a suitable message
to describe the invalid UTF-8 sequence DATA of length LEN (which
may have embedded NULLs).  We can't simply print the data, almost
by definition we don't really know how it is encoded.
Construct an error with code APR_EINVAL and with a suitable message to describe the invalid UTF - 8 sequence DATA of length LEN ( which may have embedded NULLs ) . We can ' t simply print the data almost by definition we don ' t really know how it is encoded .
static svn_error_t *
invalid_utf8(const char *data, apr_size_t len, apr_pool_t *pool)
{
  const char *last = svn_utf__last_valid(data, len);
  const char *valid_txt = "", *invalid_txt = "";
  apr_size_t i;
  size_t valid, invalid;
  valid = last - data;
  if (valid > 24)
    valid = 24;
  for (i = 0; i < valid; ++i)
    valid_txt = apr_pstrcat(pool, valid_txt,
                            apr_psprintf(pool, " %02x",
                                         (unsigned char)last[i-valid]),
                                         SVN_VA_NULL);
  invalid = data + len - last;
  if (invalid > 4)
    invalid = 4;
  for (i = 0; i < invalid; ++i)
    invalid_txt = apr_pstrcat(pool, invalid_txt,
                              apr_psprintf(pool, " %02x",
                                           (unsigned char)last[i]),
                                           SVN_VA_NULL);
  return svn_error_createf(APR_EINVAL, NULL,
                           _("Valid UTF-8 data\n(hex:%s)\n"
                             "followed by invalid UTF-8 sequence\n(hex:%s)"),
                           valid_txt, invalid_txt);
}
static svn_error_t * invalid_utf8 ( const char * data , apr_size_t len , apr_pool_t * pool ) { const char * last = svn_utf__last_valid ( data , len ) ; const char * valid_txt = " " , * invalid_txt = " " ; apr_size_t i ; size_t valid , invalid ; valid = last - data ; if ( valid > 24 ) valid = 24 ; for ( i = 0 ; i < valid ; ++ i ) valid_txt = apr_pstrcat ( pool , valid_txt , apr_psprintf ( pool , " " , ( unsigned char ) last [ i - valid ] ) , SVN_VA_NULL ) ; invalid = data + len - last ; if ( invalid > 4 ) invalid = 4 ; for ( i = 0 ; i < invalid ; ++ i ) invalid_txt = apr_pstrcat ( pool , invalid_txt , apr_psprintf ( pool , " " , ( unsigned char ) last [ i ] ) , SVN_VA_NULL ) ; return svn_error_createf ( APR_EINVAL , NULL , _ ( " \n \n " " \n " ) , valid_txt , invalid_txt ) ; }
Construct an error with code APR_EINVAL and with a suitable message
 to describe the invalid UTF-8 sequence DATA of length LEN (which
 may have embedded NULLs).
Construct an error with code APR_EINVAL and with a suitable message to describe the invalid UTF - 8 sequence DATA of length LEN ( which may have embedded NULLs ) .
/* We will display at most 24 valid octets (this may split a leading
     multi-byte character) as that should fit on one 80 character line. */ /* 4 invalid octets will guarantee that the faulty octet is displayed */