FreeBSD/contrib/subversion/subversion/libsvn_subr/utf.c
/* Return APR_EINVAL if the first LEN bytes of DATA contain anything
   other than seven-bit, non-control (except for whitespace) ASCII
   characters, finding the error pool from POOL.  Otherwise, return
   SVN_NO_ERROR. */
Return APR_EINVAL if the first LEN bytes of DATA contain anything
other than seven-bit, non-control (except for whitespace) ASCII
characters, finding the error pool from POOL.
Return APR_EINVAL if the first LEN bytes of DATA contain anything other than seven - bit non - control ( except for whitespace ) ASCII characters finding the error pool from POOL .
static svn_error_t *
check_non_ascii(const char *data, apr_size_t len, apr_pool_t *pool)
{
  const char *data_start = data;
  for (; len > 0; --len, data++)
    {
      if ((! svn_ctype_isascii(*data))
          || ((! svn_ctype_isspace(*data))
              && svn_ctype_iscntrl(*data)))
        {
          if (data - data_start)
            {
              const char *error_data
                = apr_pstrndup(pool, data_start, (data - data_start));
              return svn_error_createf
                (APR_EINVAL, NULL,
                 _("Safe data '%s' was followed by non-ASCII byte %d: "
                   "unable to convert to/from UTF-8"),
                 error_data, *((const unsigned char *) data));
            }
          else
            {
              return svn_error_createf
                (APR_EINVAL, NULL,
                 _("Non-ASCII character (code %d) detected, "
                   "and unable to convert to/from UTF-8"),
                 *((const unsigned char *) data));
            }
        }
    }
  return SVN_NO_ERROR;
}
static svn_error_t * check_non_ascii ( const char * data , apr_size_t len , apr_pool_t * pool ) { const char * data_start = data ; for ( ; len > 0 ; -- len , data ++ ) { if ( ( ! svn_ctype_isascii ( * data ) ) || ( ( ! svn_ctype_isspace ( * data ) ) && svn_ctype_iscntrl ( * data ) ) ) { if ( data - data_start ) { const char * error_data = apr_pstrndup ( pool , data_start , ( data - data_start ) ) ; return svn_error_createf ( APR_EINVAL , NULL , _ ( " " " " ) , error_data , * ( ( const unsigned char * ) data ) ) ; } else { return svn_error_createf ( APR_EINVAL , NULL , _ ( " " " " ) , * ( ( const unsigned char * ) data ) ) ; } } } return SVN_NO_ERROR ; }
Return APR_EINVAL if the first LEN bytes of DATA contain anything
other than seven-bit, non-control (except for whitespace) ASCII
characters, finding the error pool from POOL.
Return APR_EINVAL if the first LEN bytes of DATA contain anything other than seven - bit non - control ( except for whitespace ) ASCII characters finding the error pool from POOL .
/* Show the printable part of the data, followed by the
             decimal code of the questionable character.  Because if a
             user ever gets this error, she's going to have to spend
             time tracking down the non-ASCII data, so we want to help
             as much as possible.  And yes, we just call the unsafe
             data "non-ASCII", even though the actual constraint is
             somewhat more complex than that. */