File: utf8.h

package info (click to toggle)
gst-plugins-bad1.0 1.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,252 kB
  • sloc: ansic: 744,658; cpp: 300,297; objc: 3,559; xml: 3,351; sh: 1,095; python: 565; makefile: 181; java: 75
file content (128 lines) | stat: -rw-r--r-- 4,656 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**********************************************************************************************/
/* The MIT License                                                                            */
/*                                                                                            */
/* Copyright 2016-2017 Twitch Interactive, Inc. or its affiliates. All Rights Reserved.       */
/*                                                                                            */
/* Permission is hereby granted, free of charge, to any person obtaining a copy               */
/* of this software and associated documentation files (the "Software"), to deal              */
/* in the Software without restriction, including without limitation the rights               */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell                  */
/* copies of the Software, and to permit persons to whom the Software is                      */
/* furnished to do so, subject to the following conditions:                                   */
/*                                                                                            */
/* The above copyright notice and this permission notice shall be included in                 */
/* all copies or substantial portions of the Software.                                        */
/*                                                                                            */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR                 */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,                   */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE                */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER                     */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,              */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN                  */
/* THE SOFTWARE.                                                                              */
/**********************************************************************************************/
#ifndef LIBCAPTION_UTF8_H
#define LIBCAPTION_UTF8_H
#ifdef __cplusplus
extern "C" {
#endif

#include <inttypes.h>
#include <stddef.h>

// These types exist to make the code more self dcoumenting
// utf8_char_t point is a null teminate string of utf8 encodecd chars
//
// utf8_size_t is the length of a string in chars
// size_t is bytes
typedef char utf8_char_t;
typedef size_t utf8_size_t;
/*! \brief
    \param

    Skiped continuation bytes
*/

const utf8_char_t* utf8_char_next(const utf8_char_t* c);
/*! \brief
    \param

    returnes the length of the char in bytes
*/
size_t utf8_char_length(const utf8_char_t* c);

/*! \brief
    \param

    returns 1 if first charcter is white space
*/
int utf8_char_whitespace(const utf8_char_t* c);

/*! \brief
    \param

    returns length of the string in bytes
    size is number of charcter to count (0 to count until NULL term)
*/
size_t utf8_string_length(const utf8_char_t* data, utf8_size_t size);
/*! \brief
    \param
*/
size_t utf8_char_copy(utf8_char_t* dst, const utf8_char_t* src);

/*! \brief
    \param

    returnes the number of utf8 charcters in a string givne the numbe of bytes
    to coutn until the a null terminator, pass 0 for size
*/
utf8_size_t utf8_char_count(const char* data, size_t size);
/*! \brief
    \param

    returnes the length of the line in bytes triming not printable characters at the end
*/
utf8_size_t utf8_trimmed_length(const utf8_char_t* data, utf8_size_t charcters);
/*! \brief
    \param

    returns the length in bytes of the line including the new line charcter(s)
    auto detects between windows(CRLF), unix(LF), mac(CR) and riscos (LFCR) line endings
*/
size_t utf8_line_length(const utf8_char_t* data);
/*! \brief
    \param

    returns number of chars to include before split
*/
utf8_size_t utf8_wrap_length(const utf8_char_t* data, utf8_size_t size);

/*! \brief
    \param

    returns number of new lines in the string
*/
int utf8_line_count(const utf8_char_t* data);

/*! \brief
    \param
    size in/out. In the the max seize, out is the size read;
    returns number of new lins in teh string
*/
#define UFTF_DEFAULT_MAX_FILE_SIZE = (50 * 1024 * 1024);

utf8_char_t* utf8_load_text_file(const char* path, size_t* size);

/*! \brief
    \param

    Compares 2 strings up to max len
*/
#ifndef strnstr
char* strnstr(const char* string1, const char* string2, size_t len);
#endif

#ifdef __cplusplus
}
#endif
#endif