MPD: util/UTF8.hxx Source File

MPD 0.20.18

UTF8.hxx
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2011-2014 Max Kellermann <max.kellermann@gmail.com>
3 * http://www.musicpd.org
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef UTF8_HXX
32 #define UTF8_HXX
33
34 #include "Compiler.h"
35
36 #include <stddef.h>
37
41 gcc_pure gcc_nonnull_all
42 bool
43 ValidateUTF8(const char *p) noexcept;
44
49 gcc_const
50 size_t
51 SequenceLengthUTF8(char ch) noexcept;
52
57 gcc_pure
58 size_t
59 SequenceLengthUTF8(const char *p) noexcept;
60
68 gcc_pure gcc_nonnull_all
69 const char *
70 Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size) noexcept;
71
78 gcc_nonnull_all
79 char *
80 UnicodeToUTF8(unsigned ch, char *buffer) noexcept;
81
86 gcc_pure gcc_nonnull_all
87 size_t
88 LengthUTF8(const char *p) noexcept;
89
90 #endif
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
LengthUTF8
gcc_pure gcc_nonnull_all size_t LengthUTF8(const char *p) noexcept
Returns the number of characters in the string.
Latin1ToUTF8
gcc_pure gcc_nonnull_all const char * Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size) noexcept
Convert the specified string from ISO-8859-1 to UTF-8.
ValidateUTF8
gcc_pure gcc_nonnull_all bool ValidateUTF8(const char *p) noexcept
Is this a valid UTF-8 string?
Compiler.h
gcc_const
#define gcc_const
Definition: Compiler.h:109
UnicodeToUTF8
gcc_nonnull_all char * UnicodeToUTF8(unsigned ch, char *buffer) noexcept
Convert the specified Unicode character to UTF-8 and write it to the buffer.
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
SequenceLengthUTF8
gcc_const size_t SequenceLengthUTF8(char ch) noexcept