]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/subversion/subversion/include/private/svn_utf_private.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / subversion / subversion / include / private / svn_utf_private.h
1 /**
2  * @copyright
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_utf_private.h
24  * @brief UTF validation routines
25  */
26
27 #ifndef SVN_UTF_PRIVATE_H
28 #define SVN_UTF_PRIVATE_H
29
30 #include <apr.h>
31 #include <apr_pools.h>
32
33 #include "svn_types.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39
40 /* Return TRUE if the string SRC of length LEN is a valid UTF-8 encoding
41  * according to the rules laid down by the Unicode 4.0 standard, FALSE
42  * otherwise.  This function is faster than svn_utf__last_valid().
43  */
44 svn_boolean_t
45 svn_utf__is_valid(const char *src, apr_size_t len);
46
47 /* As for svn_utf__is_valid but SRC is NULL terminated. */
48 svn_boolean_t
49 svn_utf__cstring_is_valid(const char *src);
50
51 /* Return a pointer to the first character after the last valid UTF-8
52  * potentially multi-byte character in the string SRC of length LEN.
53  * Validity of bytes from SRC to SRC+LEN-1, inclusively, is checked.
54  * If SRC is a valid UTF-8, the return value will point to the byte SRC+LEN,
55  * otherwise it will point to the start of the first invalid character.
56  * In either case all the characters between SRC and the return pointer - 1,
57  * inclusively, are valid UTF-8.
58  *
59  * See also svn_utf__is_valid().
60  */
61 const char *
62 svn_utf__last_valid(const char *src, apr_size_t len);
63
64 /* As for svn_utf__last_valid but uses a different implementation without
65    lookup tables.  It avoids the table memory use (about 400 bytes) but the
66    function is longer (about 200 bytes extra) and likely to be slower when
67    the string is valid.  If the string is invalid this function may be
68    faster since it returns immediately rather than continuing to the end of
69    the string.  The main reason this function exists is to test the table
70    driven implementation.  */
71 const char *
72 svn_utf__last_valid2(const char *src, apr_size_t len);
73
74 const char *
75 svn_utf__cstring_from_utf8_fuzzy(const char *src,
76                                  apr_pool_t *pool,
77                                  svn_error_t *(*convert_from_utf8)
78                                               (const char **,
79                                                const char *,
80                                                apr_pool_t *));
81
82
83 #ifdef __cplusplus
84 }
85 #endif /* __cplusplus */
86
87 #endif /* SVN_UTF_PRIVATE_H */