bare-buffer 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +3 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/bare-buffer.bare +0 -0
- package/prebuilds/win32-x64/bare-buffer.bare +0 -0
- package/vendor/libbase64/CMakeLists.txt +14 -2
- package/vendor/libbase64/src/base64.c +18 -8
- package/vendor/libhex/CMakeLists.txt +15 -2
- package/vendor/libutf/CMakeLists.txt +19 -2
- package/vendor/libutf/include/utf/endianness.h +9 -1
- package/vendor/libutf/include/utf/string.h +759 -0
- package/vendor/libutf/include/utf.h +0 -2
- package/vendor/libutf/src/utf16/utf8-convert.c +1 -0
- package/vendor/libutf/src/utf16/utf8-length.c +1 -0
- package/vendor/libutf/src/utf16/validate.c +1 -0
- package/vendor/libutf/src/utf8/string.c +148 -0
- package/vendor/libutf/src/utf8/utf16-convert.c +1 -0
package/CMakeLists.txt
CHANGED
|
@@ -20,6 +20,9 @@ add_bare_module(bare_buffer)
|
|
|
20
20
|
|
|
21
21
|
target_sources(
|
|
22
22
|
${bare_buffer}
|
|
23
|
+
PUBLIC
|
|
24
|
+
$<TARGET_OBJECTS:base64>
|
|
25
|
+
$<TARGET_OBJECTS:hex>
|
|
23
26
|
PRIVATE
|
|
24
27
|
binding.c
|
|
25
28
|
)
|
|
@@ -27,7 +30,6 @@ target_sources(
|
|
|
27
30
|
target_link_libraries(
|
|
28
31
|
${bare_buffer}
|
|
29
32
|
PUBLIC
|
|
30
|
-
utf
|
|
31
33
|
base64
|
|
32
34
|
hex
|
|
33
35
|
)
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -30,7 +30,7 @@ target_include_directories(
|
|
|
30
30
|
$<TARGET_PROPERTY:utf,INTERFACE_INCLUDE_DIRECTORIES>
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
add_library(base64_shared SHARED
|
|
33
|
+
add_library(base64_shared SHARED)
|
|
34
34
|
|
|
35
35
|
set_target_properties(
|
|
36
36
|
base64_shared
|
|
@@ -39,7 +39,13 @@ set_target_properties(
|
|
|
39
39
|
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
target_link_libraries(
|
|
43
|
+
base64_shared
|
|
44
|
+
PUBLIC
|
|
45
|
+
base64
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
add_library(base64_static STATIC)
|
|
43
49
|
|
|
44
50
|
set_target_properties(
|
|
45
51
|
base64_static
|
|
@@ -48,6 +54,12 @@ set_target_properties(
|
|
|
48
54
|
PREFIX lib
|
|
49
55
|
)
|
|
50
56
|
|
|
57
|
+
target_link_libraries(
|
|
58
|
+
base64_static
|
|
59
|
+
PUBLIC
|
|
60
|
+
base64
|
|
61
|
+
)
|
|
62
|
+
|
|
51
63
|
install(TARGETS base64_shared base64_static)
|
|
52
64
|
|
|
53
65
|
install(FILES include/base64.h DESTINATION include)
|
|
@@ -26,21 +26,31 @@ base64_encode (const uint8_t *buffer, size_t buffer_len, utf8_t *string, size_t
|
|
|
26
26
|
|
|
27
27
|
size_t k = 0, i = 0, n = buffer_len;
|
|
28
28
|
|
|
29
|
+
uint8_t a, b, c;
|
|
30
|
+
|
|
29
31
|
for (; i + 2 < n; i += 3) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
a = buffer[i];
|
|
33
|
+
b = buffer[i + 1];
|
|
34
|
+
c = buffer[i + 2];
|
|
35
|
+
|
|
36
|
+
string[k++] = base64_alphabet[a >> 2];
|
|
37
|
+
string[k++] = base64_alphabet[((a & 0x03) << 4) | (b >> 4)];
|
|
38
|
+
string[k++] = base64_alphabet[((b & 0x0f) << 2) | (c >> 6)];
|
|
39
|
+
string[k++] = base64_alphabet[c & 0x3f];
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
if (i < n) {
|
|
37
|
-
|
|
43
|
+
a = buffer[i];
|
|
44
|
+
|
|
45
|
+
string[k++] = base64_alphabet[a >> 2];
|
|
38
46
|
|
|
39
47
|
if (i + 1 < n) {
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
b = buffer[i + 1];
|
|
49
|
+
|
|
50
|
+
string[k++] = base64_alphabet[((a & 0x03) << 4) | (b >> 4)];
|
|
51
|
+
string[k++] = base64_alphabet[(b & 0x0f) << 2];
|
|
42
52
|
} else {
|
|
43
|
-
string[k++] = base64_alphabet[(
|
|
53
|
+
string[k++] = base64_alphabet[(a & 0x03) << 4];
|
|
44
54
|
string[k++] = '=';
|
|
45
55
|
}
|
|
46
56
|
|
|
@@ -30,7 +30,7 @@ target_include_directories(
|
|
|
30
30
|
$<TARGET_PROPERTY:utf,INTERFACE_INCLUDE_DIRECTORIES>
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
add_library(hex_shared SHARED
|
|
33
|
+
add_library(hex_shared SHARED)
|
|
34
34
|
|
|
35
35
|
set_target_properties(
|
|
36
36
|
hex_shared
|
|
@@ -39,7 +39,13 @@ set_target_properties(
|
|
|
39
39
|
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
target_link_libraries(
|
|
43
|
+
hex_shared
|
|
44
|
+
PUBLIC
|
|
45
|
+
hex
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
add_library(hex_static STATIC)
|
|
43
49
|
|
|
44
50
|
set_target_properties(
|
|
45
51
|
hex_static
|
|
@@ -48,11 +54,18 @@ set_target_properties(
|
|
|
48
54
|
PREFIX lib
|
|
49
55
|
)
|
|
50
56
|
|
|
57
|
+
target_link_libraries(
|
|
58
|
+
hex_static
|
|
59
|
+
PUBLIC
|
|
60
|
+
hex
|
|
61
|
+
)
|
|
62
|
+
|
|
51
63
|
install(TARGETS hex_shared hex_static)
|
|
52
64
|
|
|
53
65
|
install(FILES include/hex.h DESTINATION include)
|
|
54
66
|
|
|
55
67
|
if(PROJECT_IS_TOP_LEVEL)
|
|
56
68
|
enable_testing()
|
|
69
|
+
|
|
57
70
|
add_subdirectory(test)
|
|
58
71
|
endif()
|
|
@@ -15,11 +15,14 @@ target_sources(
|
|
|
15
15
|
utf
|
|
16
16
|
INTERFACE
|
|
17
17
|
include/utf.h
|
|
18
|
+
include/utf/endianness.h
|
|
19
|
+
include/utf/string.h
|
|
18
20
|
PRIVATE
|
|
19
21
|
src/endianness.c
|
|
20
22
|
src/utf8/utf16-convert.c
|
|
21
23
|
src/utf8/utf16-length.c
|
|
22
24
|
src/utf8/validate.c
|
|
25
|
+
src/utf8/string.c
|
|
23
26
|
src/utf16/utf8-convert.c
|
|
24
27
|
src/utf16/utf8-length.c
|
|
25
28
|
src/utf16/validate.c
|
|
@@ -31,7 +34,7 @@ target_include_directories(
|
|
|
31
34
|
include
|
|
32
35
|
)
|
|
33
36
|
|
|
34
|
-
add_library(utf_shared SHARED
|
|
37
|
+
add_library(utf_shared SHARED)
|
|
35
38
|
|
|
36
39
|
set_target_properties(
|
|
37
40
|
utf_shared
|
|
@@ -40,7 +43,13 @@ set_target_properties(
|
|
|
40
43
|
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
|
41
44
|
)
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
target_link_libraries(
|
|
47
|
+
utf_shared
|
|
48
|
+
PUBLIC
|
|
49
|
+
utf
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
add_library(utf_static STATIC)
|
|
44
53
|
|
|
45
54
|
set_target_properties(
|
|
46
55
|
utf_static
|
|
@@ -49,10 +58,18 @@ set_target_properties(
|
|
|
49
58
|
PREFIX lib
|
|
50
59
|
)
|
|
51
60
|
|
|
61
|
+
target_link_libraries(
|
|
62
|
+
utf_static
|
|
63
|
+
PUBLIC
|
|
64
|
+
utf
|
|
65
|
+
)
|
|
66
|
+
|
|
52
67
|
install(TARGETS utf_shared utf_static)
|
|
53
68
|
|
|
54
69
|
install(FILES include/utf.h DESTINATION include)
|
|
55
70
|
|
|
71
|
+
install(DIRECTORY include/utf DESTINATION include)
|
|
72
|
+
|
|
56
73
|
if(PROJECT_IS_TOP_LEVEL)
|
|
57
74
|
enable_testing()
|
|
58
75
|
add_subdirectory(test)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#ifndef UTF_ENDIANNESS_H
|
|
2
2
|
#define UTF_ENDIANNESS_H
|
|
3
3
|
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
4
8
|
#include <stdbool.h>
|
|
5
9
|
#include <stdint.h>
|
|
6
10
|
|
|
@@ -43,4 +47,8 @@ utf_swap_uint32 (uint32_t n) {
|
|
|
43
47
|
((n & 0xff000000) >> 24);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
#
|
|
50
|
+
#ifdef __cplusplus
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
#endif // UTF_ENDIANNESS_H
|
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
#ifndef UTF_STRING_H
|
|
2
|
+
#define UTF_STRING_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <assert.h>
|
|
9
|
+
#include <stdbool.h>
|
|
10
|
+
#include <stddef.h>
|
|
11
|
+
#include <stdio.h>
|
|
12
|
+
#include <stdlib.h>
|
|
13
|
+
#include <string.h>
|
|
14
|
+
|
|
15
|
+
#include "../utf.h"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* UTF-8
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
typedef struct utf8_string_s utf8_string_t;
|
|
22
|
+
typedef struct utf8_string_view_s utf8_string_view_t;
|
|
23
|
+
|
|
24
|
+
struct utf8_string_s {
|
|
25
|
+
utf8_t *data;
|
|
26
|
+
size_t len;
|
|
27
|
+
size_t cap;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
struct utf8_string_view_s {
|
|
31
|
+
const utf8_t *data;
|
|
32
|
+
size_t len;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
inline void
|
|
36
|
+
utf8_string_init (utf8_string_t *string) {
|
|
37
|
+
string->len = 0;
|
|
38
|
+
string->cap = 0;
|
|
39
|
+
string->data = NULL;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
inline utf8_string_view_t
|
|
43
|
+
utf8_string_view_init (const utf8_t *data, size_t len) {
|
|
44
|
+
return (utf8_string_view_t){data, len};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
inline void
|
|
48
|
+
utf8_string_destroy (utf8_string_t *string) {
|
|
49
|
+
free(string->data);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
inline int
|
|
53
|
+
utf8_string_reserve (utf8_string_t *string, size_t len) {
|
|
54
|
+
size_t cap = string->cap;
|
|
55
|
+
|
|
56
|
+
if (len < cap) return 0;
|
|
57
|
+
|
|
58
|
+
if (cap == 0) cap = sizeof(utf8_string_t) - 1;
|
|
59
|
+
|
|
60
|
+
while (cap < len) {
|
|
61
|
+
cap = cap * 2 + 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void *data = realloc(string->data, cap);
|
|
65
|
+
|
|
66
|
+
if (data == NULL) return -1;
|
|
67
|
+
|
|
68
|
+
string->cap = cap;
|
|
69
|
+
string->data = data;
|
|
70
|
+
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
inline int
|
|
75
|
+
utf8_string_shrink_to_fit (utf8_string_t *string) {
|
|
76
|
+
size_t cap = string->len + 1;
|
|
77
|
+
|
|
78
|
+
void *data = realloc(string->data, cap);
|
|
79
|
+
|
|
80
|
+
if (data == NULL) return -1;
|
|
81
|
+
|
|
82
|
+
string->cap = cap;
|
|
83
|
+
string->data = data;
|
|
84
|
+
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
inline utf8_string_view_t
|
|
89
|
+
utf8_string_view (const utf8_string_t *string) {
|
|
90
|
+
return utf8_string_view_init(string->data, string->len);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
inline void
|
|
94
|
+
utf8_string_clear (utf8_string_t *string) {
|
|
95
|
+
string->len = 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
inline bool
|
|
99
|
+
utf8_string_empty (utf8_string_t *string) {
|
|
100
|
+
return string->len == 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
inline bool
|
|
104
|
+
utf8_string_view_empty (const utf8_string_view_t view) {
|
|
105
|
+
return view.len == 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
inline int
|
|
109
|
+
utf8_string_copy (const utf8_string_t *string, utf8_string_t *result) {
|
|
110
|
+
int err;
|
|
111
|
+
|
|
112
|
+
err = utf8_string_reserve(result, string->len);
|
|
113
|
+
if (err < 0) return err;
|
|
114
|
+
|
|
115
|
+
memcpy(result->data, string->data, string->len);
|
|
116
|
+
|
|
117
|
+
result->len = string->len;
|
|
118
|
+
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
inline int
|
|
123
|
+
utf8_string_view_copy (const utf8_string_view_t view, utf8_string_t *result) {
|
|
124
|
+
int err;
|
|
125
|
+
|
|
126
|
+
err = utf8_string_reserve(result, view.len);
|
|
127
|
+
if (err < 0) return err;
|
|
128
|
+
|
|
129
|
+
memcpy(result->data, view.data, view.len);
|
|
130
|
+
|
|
131
|
+
result->len = view.len;
|
|
132
|
+
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
inline int
|
|
137
|
+
utf8_string_append (utf8_string_t *string, const utf8_string_t *other) {
|
|
138
|
+
int err;
|
|
139
|
+
|
|
140
|
+
err = utf8_string_reserve(string, string->len + other->len);
|
|
141
|
+
if (err < 0) return -1;
|
|
142
|
+
|
|
143
|
+
memcpy(&string->data[string->len], other->data, other->len);
|
|
144
|
+
|
|
145
|
+
string->len += other->len;
|
|
146
|
+
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
inline int
|
|
151
|
+
utf8_string_append_view (utf8_string_t *string, const utf8_string_view_t view) {
|
|
152
|
+
int err;
|
|
153
|
+
|
|
154
|
+
err = utf8_string_reserve(string, string->len + view.len);
|
|
155
|
+
if (err < 0) return -1;
|
|
156
|
+
|
|
157
|
+
memcpy(&string->data[string->len], view.data, view.len);
|
|
158
|
+
|
|
159
|
+
string->len += view.len;
|
|
160
|
+
|
|
161
|
+
return 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
inline int
|
|
165
|
+
utf8_string_append_character (utf8_string_t *string, utf8_t c) {
|
|
166
|
+
int err;
|
|
167
|
+
|
|
168
|
+
err = utf8_string_reserve(string, string->len + 1);
|
|
169
|
+
if (err < 0) return -1;
|
|
170
|
+
|
|
171
|
+
string->data[string->len] = c;
|
|
172
|
+
|
|
173
|
+
string->len += 1;
|
|
174
|
+
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
inline int
|
|
179
|
+
utf8_string_append_literal (utf8_string_t *string, const utf8_t *literal, size_t n) {
|
|
180
|
+
int err;
|
|
181
|
+
|
|
182
|
+
if (n == (size_t) -1) n = strlen((const char *) literal);
|
|
183
|
+
|
|
184
|
+
err = utf8_string_reserve(string, string->len + n);
|
|
185
|
+
if (err < 0) return -1;
|
|
186
|
+
|
|
187
|
+
memcpy(&string->data[string->len], literal, n);
|
|
188
|
+
|
|
189
|
+
string->len += n;
|
|
190
|
+
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline int
|
|
195
|
+
utf8_string_prepend (utf8_string_t *string, const utf8_string_t *other) {
|
|
196
|
+
int err;
|
|
197
|
+
|
|
198
|
+
err = utf8_string_reserve(string, string->len + other->len);
|
|
199
|
+
if (err < 0) return -1;
|
|
200
|
+
|
|
201
|
+
memmove(&string->data[other->len], string->data, string->len);
|
|
202
|
+
|
|
203
|
+
memcpy(string->data, other->data, other->len);
|
|
204
|
+
|
|
205
|
+
string->len += other->len;
|
|
206
|
+
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
inline int
|
|
211
|
+
utf8_string_prepend_view (utf8_string_t *string, const utf8_string_view_t view) {
|
|
212
|
+
int err;
|
|
213
|
+
|
|
214
|
+
err = utf8_string_reserve(string, string->len + view.len);
|
|
215
|
+
if (err < 0) return -1;
|
|
216
|
+
|
|
217
|
+
memmove(&string->data[view.len], string->data, string->len);
|
|
218
|
+
|
|
219
|
+
memcpy(string->data, view.data, view.len);
|
|
220
|
+
|
|
221
|
+
string->len += view.len;
|
|
222
|
+
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
inline int
|
|
227
|
+
utf8_string_prepend_character (utf8_string_t *string, utf8_t c) {
|
|
228
|
+
int err;
|
|
229
|
+
|
|
230
|
+
err = utf8_string_reserve(string, string->len + 1);
|
|
231
|
+
if (err < 0) return -1;
|
|
232
|
+
|
|
233
|
+
memmove(&string->data[1], string->data, string->len);
|
|
234
|
+
|
|
235
|
+
string->data[0] = c;
|
|
236
|
+
|
|
237
|
+
string->len += 1;
|
|
238
|
+
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
inline int
|
|
243
|
+
utf8_string_prepend_literal (utf8_string_t *string, const utf8_t *literal, size_t n) {
|
|
244
|
+
int err;
|
|
245
|
+
|
|
246
|
+
if (n == (size_t) -1) n = strlen((const char *) literal);
|
|
247
|
+
|
|
248
|
+
err = utf8_string_reserve(string, string->len + n);
|
|
249
|
+
if (err < 0) return -1;
|
|
250
|
+
|
|
251
|
+
memmove(&string->data[n], string->data, string->len);
|
|
252
|
+
|
|
253
|
+
memcpy(string->data, literal, n);
|
|
254
|
+
|
|
255
|
+
string->len += n;
|
|
256
|
+
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
inline int
|
|
261
|
+
utf8_string_insert (utf8_string_t *string, size_t pos, const utf8_string_t *other) {
|
|
262
|
+
int err;
|
|
263
|
+
|
|
264
|
+
if (pos > string->len) return -1;
|
|
265
|
+
|
|
266
|
+
size_t inserted_len = string->len + other->len;
|
|
267
|
+
|
|
268
|
+
err = utf8_string_reserve(string, inserted_len);
|
|
269
|
+
if (err < 0) return err;
|
|
270
|
+
|
|
271
|
+
memmove(&string->data[pos + other->len], &string->data[pos], string->len - pos);
|
|
272
|
+
|
|
273
|
+
memcpy(&string->data[pos], other->data, other->len);
|
|
274
|
+
|
|
275
|
+
string->len = inserted_len;
|
|
276
|
+
|
|
277
|
+
return 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
inline int
|
|
281
|
+
utf8_string_insert_view (utf8_string_t *string, size_t pos, const utf8_string_view_t other) {
|
|
282
|
+
int err;
|
|
283
|
+
|
|
284
|
+
if (pos > string->len) return -1;
|
|
285
|
+
|
|
286
|
+
size_t inserted_len = string->len + other.len;
|
|
287
|
+
|
|
288
|
+
err = utf8_string_reserve(string, inserted_len);
|
|
289
|
+
if (err < 0) return err;
|
|
290
|
+
|
|
291
|
+
memmove(&string->data[pos + other.len], &string->data[pos], string->len - pos);
|
|
292
|
+
|
|
293
|
+
memcpy(&string->data[pos], other.data, other.len);
|
|
294
|
+
|
|
295
|
+
string->len = inserted_len;
|
|
296
|
+
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
inline int
|
|
301
|
+
utf8_string_insert_character (utf8_string_t *string, size_t pos, utf8_t c) {
|
|
302
|
+
int err;
|
|
303
|
+
|
|
304
|
+
if (pos > string->len) return -1;
|
|
305
|
+
|
|
306
|
+
size_t inserted_len = string->len + 1;
|
|
307
|
+
|
|
308
|
+
err = utf8_string_reserve(string, inserted_len);
|
|
309
|
+
if (err < 0) return err;
|
|
310
|
+
|
|
311
|
+
memmove(&string->data[pos + 1], &string->data[pos], string->len - pos);
|
|
312
|
+
|
|
313
|
+
string->data[pos] = c;
|
|
314
|
+
|
|
315
|
+
string->len = inserted_len;
|
|
316
|
+
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
inline int
|
|
321
|
+
utf8_string_insert_literal (utf8_string_t *string, size_t pos, const utf8_t *literal, size_t n) {
|
|
322
|
+
int err;
|
|
323
|
+
|
|
324
|
+
if (pos > string->len) return -1;
|
|
325
|
+
|
|
326
|
+
if (n == (size_t) -1) n = strlen((const char *) literal);
|
|
327
|
+
|
|
328
|
+
size_t inserted_len = string->len + n;
|
|
329
|
+
|
|
330
|
+
err = utf8_string_reserve(string, inserted_len);
|
|
331
|
+
if (err < 0) return err;
|
|
332
|
+
|
|
333
|
+
memmove(&string->data[pos + n], &string->data[pos], string->len - pos);
|
|
334
|
+
|
|
335
|
+
memcpy(&string->data[pos], literal, n);
|
|
336
|
+
|
|
337
|
+
string->len = inserted_len;
|
|
338
|
+
|
|
339
|
+
return 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
inline int
|
|
343
|
+
utf8_string_replace (utf8_string_t *string, size_t pos, size_t len, const utf8_string_t *replacement) {
|
|
344
|
+
int err;
|
|
345
|
+
|
|
346
|
+
if (pos > string->len) return -1;
|
|
347
|
+
if (pos + len > string->len) len = string->len - pos;
|
|
348
|
+
|
|
349
|
+
size_t replaced_len = string->len + replacement->len - len;
|
|
350
|
+
|
|
351
|
+
err = utf8_string_reserve(string, replaced_len);
|
|
352
|
+
if (err < 0) return err;
|
|
353
|
+
|
|
354
|
+
memmove(&string->data[pos + replacement->len], &string->data[pos + len], string->len - pos - len);
|
|
355
|
+
|
|
356
|
+
memcpy(&string->data[pos], replacement->data, replacement->len);
|
|
357
|
+
|
|
358
|
+
string->len = replaced_len;
|
|
359
|
+
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
inline int
|
|
364
|
+
utf8_string_replace_view (utf8_string_t *string, size_t pos, size_t len, const utf8_string_view_t replacement) {
|
|
365
|
+
int err;
|
|
366
|
+
|
|
367
|
+
if (pos > string->len) return -1;
|
|
368
|
+
if (pos + len > string->len) len = string->len - pos;
|
|
369
|
+
|
|
370
|
+
size_t replaced_len = string->len + replacement.len - len;
|
|
371
|
+
|
|
372
|
+
err = utf8_string_reserve(string, replaced_len);
|
|
373
|
+
if (err < 0) return err;
|
|
374
|
+
|
|
375
|
+
memmove(&string->data[pos + replacement.len], &string->data[pos + len], string->len - pos - len);
|
|
376
|
+
|
|
377
|
+
memcpy(&string->data[pos], replacement.data, replacement.len);
|
|
378
|
+
|
|
379
|
+
string->len = replaced_len;
|
|
380
|
+
|
|
381
|
+
return 0;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
inline int
|
|
385
|
+
utf8_string_replace_character (utf8_string_t *string, size_t pos, size_t len, utf8_t c) {
|
|
386
|
+
int err;
|
|
387
|
+
|
|
388
|
+
if (pos > string->len) return -1;
|
|
389
|
+
|
|
390
|
+
size_t replaced_len = string->len + 1 - len;
|
|
391
|
+
|
|
392
|
+
err = utf8_string_reserve(string, replaced_len);
|
|
393
|
+
if (err < 0) return err;
|
|
394
|
+
|
|
395
|
+
memmove(&string->data[pos + 1], &string->data[pos + len], string->len - pos - len);
|
|
396
|
+
|
|
397
|
+
string->data[pos] = c;
|
|
398
|
+
|
|
399
|
+
string->len = replaced_len;
|
|
400
|
+
|
|
401
|
+
return 0;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
inline int
|
|
405
|
+
utf8_string_replace_literal (utf8_string_t *string, size_t pos, size_t len, const utf8_t *literal, size_t n) {
|
|
406
|
+
int err;
|
|
407
|
+
|
|
408
|
+
if (pos > string->len) return -1;
|
|
409
|
+
if (pos + len > string->len) len = string->len - pos;
|
|
410
|
+
|
|
411
|
+
if (n == (size_t) -1) n = strlen((const char *) literal);
|
|
412
|
+
|
|
413
|
+
size_t replaced_len = string->len + n - len;
|
|
414
|
+
|
|
415
|
+
err = utf8_string_reserve(string, replaced_len);
|
|
416
|
+
if (err < 0) return err;
|
|
417
|
+
|
|
418
|
+
memmove(&string->data[pos + n], &string->data[pos + len], string->len - pos - len);
|
|
419
|
+
|
|
420
|
+
memcpy(&string->data[pos], literal, n);
|
|
421
|
+
|
|
422
|
+
string->len = replaced_len;
|
|
423
|
+
|
|
424
|
+
return 0;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
inline int
|
|
428
|
+
utf8_string_erase (utf8_string_t *string, size_t pos, size_t len) {
|
|
429
|
+
int err;
|
|
430
|
+
|
|
431
|
+
if (pos > string->len) return -1;
|
|
432
|
+
if (pos + len > string->len) len = string->len - pos;
|
|
433
|
+
|
|
434
|
+
memmove(&string->data[pos], &string->data[pos + len], string->len - pos - len);
|
|
435
|
+
|
|
436
|
+
string->len -= len;
|
|
437
|
+
|
|
438
|
+
return 0;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
inline int
|
|
442
|
+
utf8_string_concat (const utf8_string_t *string, const utf8_string_t *other, utf8_string_t *result) {
|
|
443
|
+
int err;
|
|
444
|
+
|
|
445
|
+
utf8_string_init(result);
|
|
446
|
+
|
|
447
|
+
err = utf8_string_reserve(result, string->len + other->len);
|
|
448
|
+
if (err < 0) return err;
|
|
449
|
+
|
|
450
|
+
err = utf8_string_append(result, string);
|
|
451
|
+
assert(err == 0);
|
|
452
|
+
|
|
453
|
+
err = utf8_string_append(result, other);
|
|
454
|
+
assert(err == 0);
|
|
455
|
+
|
|
456
|
+
return 0;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
inline int
|
|
460
|
+
utf8_string_view_concat (const utf8_string_view_t view, const utf8_string_t *other, utf8_string_t *result) {
|
|
461
|
+
int err;
|
|
462
|
+
|
|
463
|
+
utf8_string_init(result);
|
|
464
|
+
|
|
465
|
+
err = utf8_string_reserve(result, view.len + other->len);
|
|
466
|
+
if (err < 0) return err;
|
|
467
|
+
|
|
468
|
+
err = utf8_string_append_view(result, view);
|
|
469
|
+
assert(err == 0);
|
|
470
|
+
|
|
471
|
+
err = utf8_string_append(result, other);
|
|
472
|
+
assert(err == 0);
|
|
473
|
+
|
|
474
|
+
return 0;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
inline int
|
|
478
|
+
utf8_string_concat_view (const utf8_string_t *string, const utf8_string_view_t other, utf8_string_t *result) {
|
|
479
|
+
int err;
|
|
480
|
+
|
|
481
|
+
utf8_string_init(result);
|
|
482
|
+
|
|
483
|
+
err = utf8_string_reserve(result, string->len + other.len);
|
|
484
|
+
if (err < 0) return err;
|
|
485
|
+
|
|
486
|
+
err = utf8_string_append(result, string);
|
|
487
|
+
assert(err == 0);
|
|
488
|
+
|
|
489
|
+
err = utf8_string_append_view(result, other);
|
|
490
|
+
assert(err == 0);
|
|
491
|
+
|
|
492
|
+
return 0;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
inline int
|
|
496
|
+
utf8_string_view_concat_view (const utf8_string_view_t view, const utf8_string_view_t other, utf8_string_t *result) {
|
|
497
|
+
int err;
|
|
498
|
+
|
|
499
|
+
utf8_string_init(result);
|
|
500
|
+
|
|
501
|
+
err = utf8_string_reserve(result, view.len + other.len);
|
|
502
|
+
if (err < 0) return err;
|
|
503
|
+
|
|
504
|
+
err = utf8_string_append_view(result, view);
|
|
505
|
+
assert(err == 0);
|
|
506
|
+
|
|
507
|
+
err = utf8_string_append_view(result, other);
|
|
508
|
+
assert(err == 0);
|
|
509
|
+
|
|
510
|
+
return 0;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
inline int
|
|
514
|
+
utf8_string_concat_character (const utf8_string_t *string, utf8_t c, utf8_string_t *result) {
|
|
515
|
+
int err;
|
|
516
|
+
|
|
517
|
+
utf8_string_init(result);
|
|
518
|
+
|
|
519
|
+
err = utf8_string_reserve(result, string->len + 1);
|
|
520
|
+
if (err < 0) return err;
|
|
521
|
+
|
|
522
|
+
err = utf8_string_append(result, string);
|
|
523
|
+
assert(err == 0);
|
|
524
|
+
|
|
525
|
+
err = utf8_string_append_character(result, c);
|
|
526
|
+
assert(err == 0);
|
|
527
|
+
|
|
528
|
+
return 0;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
inline int
|
|
532
|
+
utf8_string_view_concat_character (const utf8_string_view_t view, utf8_t c, utf8_string_t *result) {
|
|
533
|
+
int err;
|
|
534
|
+
|
|
535
|
+
utf8_string_init(result);
|
|
536
|
+
|
|
537
|
+
err = utf8_string_reserve(result, view.len + 1);
|
|
538
|
+
if (err < 0) return err;
|
|
539
|
+
|
|
540
|
+
err = utf8_string_append_view(result, view);
|
|
541
|
+
assert(err == 0);
|
|
542
|
+
|
|
543
|
+
err = utf8_string_append_character(result, c);
|
|
544
|
+
assert(err == 0);
|
|
545
|
+
|
|
546
|
+
return 0;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
inline int
|
|
550
|
+
utf8_string_concat_literal (const utf8_string_t *string, const utf8_t *literal, size_t n, utf8_string_t *result) {
|
|
551
|
+
int err;
|
|
552
|
+
|
|
553
|
+
utf8_string_init(result);
|
|
554
|
+
|
|
555
|
+
err = utf8_string_reserve(result, string->len + n);
|
|
556
|
+
if (err < 0) return err;
|
|
557
|
+
|
|
558
|
+
err = utf8_string_append(result, string);
|
|
559
|
+
assert(err == 0);
|
|
560
|
+
|
|
561
|
+
err = utf8_string_append_literal(result, literal, n);
|
|
562
|
+
assert(err == 0);
|
|
563
|
+
|
|
564
|
+
return 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
inline int
|
|
568
|
+
utf8_string_view_concat_literal (const utf8_string_view_t view, const utf8_t *literal, size_t n, utf8_string_t *result) {
|
|
569
|
+
int err;
|
|
570
|
+
|
|
571
|
+
utf8_string_init(result);
|
|
572
|
+
|
|
573
|
+
err = utf8_string_reserve(result, view.len + n);
|
|
574
|
+
if (err < 0) return err;
|
|
575
|
+
|
|
576
|
+
err = utf8_string_append_view(result, view);
|
|
577
|
+
assert(err == 0);
|
|
578
|
+
|
|
579
|
+
err = utf8_string_append_literal(result, literal, n);
|
|
580
|
+
assert(err == 0);
|
|
581
|
+
|
|
582
|
+
return 0;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
inline int
|
|
586
|
+
utf8_string_compare (const utf8_string_t *string, const utf8_string_t *other) {
|
|
587
|
+
size_t a_len = string->len;
|
|
588
|
+
size_t b_len = other->len;
|
|
589
|
+
|
|
590
|
+
int result = strncmp((const char *) string->data, (const char *) other->data, a_len < b_len ? a_len : b_len);
|
|
591
|
+
|
|
592
|
+
if (result == 0) return a_len < b_len
|
|
593
|
+
? -1
|
|
594
|
+
: a_len > b_len ? 1
|
|
595
|
+
: 0;
|
|
596
|
+
|
|
597
|
+
return result;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
inline int
|
|
601
|
+
utf8_string_view_compare (const utf8_string_view_t view, const utf8_string_view_t other) {
|
|
602
|
+
size_t a_len = view.len;
|
|
603
|
+
size_t b_len = other.len;
|
|
604
|
+
|
|
605
|
+
int result = strncmp((const char *) view.data, (const char *) other.data, a_len < b_len ? a_len : b_len);
|
|
606
|
+
|
|
607
|
+
if (result == 0) return a_len < b_len
|
|
608
|
+
? -1
|
|
609
|
+
: a_len > b_len ? 1
|
|
610
|
+
: 0;
|
|
611
|
+
|
|
612
|
+
return result;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
inline int
|
|
616
|
+
utf8_string_compare_literal (const utf8_string_t *string, const utf8_t *literal, size_t n) {
|
|
617
|
+
if (n == (size_t) -1) n = strlen((const char *) literal);
|
|
618
|
+
|
|
619
|
+
size_t a_len = string->len;
|
|
620
|
+
size_t b_len = n;
|
|
621
|
+
|
|
622
|
+
int result = strncmp((const char *) string->data, (const char *) literal, a_len < b_len ? a_len : b_len);
|
|
623
|
+
|
|
624
|
+
if (result == 0) return a_len < b_len
|
|
625
|
+
? -1
|
|
626
|
+
: a_len > b_len ? 1
|
|
627
|
+
: 0;
|
|
628
|
+
|
|
629
|
+
return result;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
inline int
|
|
633
|
+
utf8_string_view_compare_literal (const utf8_string_view_t view, const utf8_t *literal, size_t n) {
|
|
634
|
+
if (n == (size_t) -1) n = strlen((const char *) literal);
|
|
635
|
+
|
|
636
|
+
size_t a_len = view.len;
|
|
637
|
+
size_t b_len = n;
|
|
638
|
+
|
|
639
|
+
int result = strncmp((const char *) view.data, (const char *) literal, a_len < b_len ? a_len : b_len);
|
|
640
|
+
|
|
641
|
+
if (result == 0) return a_len < b_len
|
|
642
|
+
? -1
|
|
643
|
+
: a_len > b_len ? 1
|
|
644
|
+
: 0;
|
|
645
|
+
|
|
646
|
+
return result;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
inline utf8_string_view_t
|
|
650
|
+
utf8_string_substring (const utf8_string_t *string, size_t start, size_t end) {
|
|
651
|
+
if (end == (size_t) -1 || end > string->len) end = string->len;
|
|
652
|
+
if (start > end) start = end;
|
|
653
|
+
|
|
654
|
+
return utf8_string_view_init(&string->data[start], end - start);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
inline utf8_string_view_t
|
|
658
|
+
utf8_string_view_substring (const utf8_string_view_t view, size_t start, size_t end) {
|
|
659
|
+
if (end == (size_t) -1 || end > view.len) end = view.len;
|
|
660
|
+
if (start > end) start = end;
|
|
661
|
+
|
|
662
|
+
return utf8_string_view_init(&view.data[start], end - start);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
inline int
|
|
666
|
+
utf8_string_substring_copy (const utf8_string_t *string, size_t start, size_t end, utf8_string_t *result) {
|
|
667
|
+
int err;
|
|
668
|
+
|
|
669
|
+
if (end == (size_t) -1 || end > string->len) end = string->len;
|
|
670
|
+
if (start > end) start = end;
|
|
671
|
+
|
|
672
|
+
utf8_string_init(result);
|
|
673
|
+
|
|
674
|
+
size_t len = end - start;
|
|
675
|
+
|
|
676
|
+
err = utf8_string_reserve(result, len);
|
|
677
|
+
if (err < 0) return -1;
|
|
678
|
+
|
|
679
|
+
memcpy(result->data, &string->data[start], len);
|
|
680
|
+
|
|
681
|
+
result->len = len;
|
|
682
|
+
|
|
683
|
+
return 0;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
inline int
|
|
687
|
+
utf8_string_view_substring_copy (const utf8_string_view_t view, size_t start, size_t end, utf8_string_t *result) {
|
|
688
|
+
int err;
|
|
689
|
+
|
|
690
|
+
if (end == (size_t) -1 || end > view.len) end = view.len;
|
|
691
|
+
if (start > end) start = end;
|
|
692
|
+
|
|
693
|
+
size_t len = end - start;
|
|
694
|
+
|
|
695
|
+
err = utf8_string_reserve(result, len);
|
|
696
|
+
if (err < 0) return -1;
|
|
697
|
+
|
|
698
|
+
memcpy(result->data, &view.data[start], len);
|
|
699
|
+
|
|
700
|
+
result->len = len;
|
|
701
|
+
|
|
702
|
+
return 0;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
inline size_t
|
|
706
|
+
utf8_string_index_of_character (const utf8_string_t *string, size_t pos, utf8_t c) {
|
|
707
|
+
for (size_t i = pos, n = string->len; i < n; i++) {
|
|
708
|
+
if (string->data[i] == c) {
|
|
709
|
+
return i;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return (size_t) -1;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
inline size_t
|
|
717
|
+
utf8_string_view_index_of_character (const utf8_string_view_t view, size_t pos, utf8_t c) {
|
|
718
|
+
for (size_t i = pos, n = view.len; i < n; i++) {
|
|
719
|
+
if (view.data[i] == c) {
|
|
720
|
+
return i;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return (size_t) -1;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
inline size_t
|
|
728
|
+
utf8_string_last_index_of_character (const utf8_string_t *string, size_t pos, utf8_t c) {
|
|
729
|
+
if (pos == (size_t) -1) pos = string->len - 1;
|
|
730
|
+
else if (pos >= string->len) return (size_t) -1;
|
|
731
|
+
|
|
732
|
+
for (size_t i = pos; i <= pos; i--) {
|
|
733
|
+
if (string->data[i] == c) {
|
|
734
|
+
return i;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
return (size_t) -1;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
inline size_t
|
|
742
|
+
utf8_string_view_last_index_of_character (const utf8_string_view_t view, size_t pos, utf8_t c) {
|
|
743
|
+
if (pos == (size_t) -1) pos = view.len - 1;
|
|
744
|
+
else if (pos >= view.len) return (size_t) -1;
|
|
745
|
+
|
|
746
|
+
for (size_t i = pos; i <= pos; i--) {
|
|
747
|
+
if (view.data[i] == c) {
|
|
748
|
+
return i;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return (size_t) -1;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
#ifdef __cplusplus
|
|
756
|
+
}
|
|
757
|
+
#endif
|
|
758
|
+
|
|
759
|
+
#endif // UTF_STRING_H
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#include <stddef.h>
|
|
2
|
+
|
|
3
|
+
#include "../../include/utf.h"
|
|
4
|
+
#include "../../include/utf/string.h"
|
|
5
|
+
|
|
6
|
+
extern void
|
|
7
|
+
utf8_string_init (utf8_string_t *string);
|
|
8
|
+
|
|
9
|
+
extern utf8_string_view_t
|
|
10
|
+
utf8_string_view_init (const utf8_t *data, size_t len);
|
|
11
|
+
|
|
12
|
+
extern void
|
|
13
|
+
utf8_string_destroy (utf8_string_t *string);
|
|
14
|
+
|
|
15
|
+
extern int
|
|
16
|
+
utf8_string_reserve (utf8_string_t *string, size_t len);
|
|
17
|
+
|
|
18
|
+
extern int
|
|
19
|
+
utf8_string_shrink_to_fit (utf8_string_t *string);
|
|
20
|
+
|
|
21
|
+
extern utf8_string_view_t
|
|
22
|
+
utf8_string_view (const utf8_string_t *string);
|
|
23
|
+
|
|
24
|
+
extern void
|
|
25
|
+
utf8_string_clear (utf8_string_t *string);
|
|
26
|
+
|
|
27
|
+
extern bool
|
|
28
|
+
utf8_string_empty (utf8_string_t *string);
|
|
29
|
+
|
|
30
|
+
extern bool
|
|
31
|
+
utf8_string_view_empty (const utf8_string_view_t view);
|
|
32
|
+
|
|
33
|
+
extern int
|
|
34
|
+
utf8_string_copy (const utf8_string_t *string, utf8_string_t *result);
|
|
35
|
+
|
|
36
|
+
extern int
|
|
37
|
+
utf8_string_view_copy (const utf8_string_view_t view, utf8_string_t *result);
|
|
38
|
+
|
|
39
|
+
extern int
|
|
40
|
+
utf8_string_append (utf8_string_t *string, const utf8_string_t *other);
|
|
41
|
+
|
|
42
|
+
extern int
|
|
43
|
+
utf8_string_append_view (utf8_string_t *string, const utf8_string_view_t view);
|
|
44
|
+
|
|
45
|
+
extern int
|
|
46
|
+
utf8_string_append_character (utf8_string_t *string, utf8_t c);
|
|
47
|
+
|
|
48
|
+
extern int
|
|
49
|
+
utf8_string_append_literal (utf8_string_t *string, const utf8_t *literal, size_t n);
|
|
50
|
+
|
|
51
|
+
extern int
|
|
52
|
+
utf8_string_prepend (utf8_string_t *string, const utf8_string_t *other);
|
|
53
|
+
|
|
54
|
+
extern int
|
|
55
|
+
utf8_string_prepend_view (utf8_string_t *string, const utf8_string_view_t view);
|
|
56
|
+
|
|
57
|
+
extern int
|
|
58
|
+
utf8_string_prepend_character (utf8_string_t *string, utf8_t c);
|
|
59
|
+
|
|
60
|
+
extern int
|
|
61
|
+
utf8_string_prepend_literal (utf8_string_t *string, const utf8_t *literal, size_t n);
|
|
62
|
+
|
|
63
|
+
extern int
|
|
64
|
+
utf8_string_insert (utf8_string_t *string, size_t pos, const utf8_string_t *other);
|
|
65
|
+
|
|
66
|
+
extern int
|
|
67
|
+
utf8_string_insert_view (utf8_string_t *string, size_t pos, const utf8_string_view_t other);
|
|
68
|
+
|
|
69
|
+
extern int
|
|
70
|
+
utf8_string_insert_character (utf8_string_t *string, size_t pos, utf8_t c);
|
|
71
|
+
|
|
72
|
+
extern int
|
|
73
|
+
utf8_string_insert_literal (utf8_string_t *string, size_t pos, const utf8_t *literal, size_t n);
|
|
74
|
+
|
|
75
|
+
extern int
|
|
76
|
+
utf8_string_replace (utf8_string_t *string, size_t pos, size_t len, const utf8_string_t *replacement);
|
|
77
|
+
|
|
78
|
+
extern int
|
|
79
|
+
utf8_string_replace_view (utf8_string_t *string, size_t pos, size_t len, const utf8_string_view_t replacement);
|
|
80
|
+
|
|
81
|
+
extern int
|
|
82
|
+
utf8_string_replace_character (utf8_string_t *string, size_t pos, size_t len, utf8_t c);
|
|
83
|
+
|
|
84
|
+
extern int
|
|
85
|
+
utf8_string_replace_literal (utf8_string_t *string, size_t pos, size_t len, const utf8_t *literal, size_t n);
|
|
86
|
+
|
|
87
|
+
extern int
|
|
88
|
+
utf8_string_erase (utf8_string_t *string, size_t pos, size_t len);
|
|
89
|
+
|
|
90
|
+
extern int
|
|
91
|
+
utf8_string_concat (const utf8_string_t *string, const utf8_string_t *other, utf8_string_t *result);
|
|
92
|
+
|
|
93
|
+
extern int
|
|
94
|
+
utf8_string_view_concat (const utf8_string_view_t view, const utf8_string_t *other, utf8_string_t *result);
|
|
95
|
+
|
|
96
|
+
extern int
|
|
97
|
+
utf8_string_concat_view (const utf8_string_t *string, const utf8_string_view_t other, utf8_string_t *result);
|
|
98
|
+
|
|
99
|
+
extern int
|
|
100
|
+
utf8_string_view_concat_view (const utf8_string_view_t view, const utf8_string_view_t other, utf8_string_t *result);
|
|
101
|
+
|
|
102
|
+
extern int
|
|
103
|
+
utf8_string_concat_character (const utf8_string_t *string, utf8_t c, utf8_string_t *result);
|
|
104
|
+
|
|
105
|
+
extern int
|
|
106
|
+
utf8_string_view_concat_character (const utf8_string_view_t view, utf8_t c, utf8_string_t *result);
|
|
107
|
+
|
|
108
|
+
extern int
|
|
109
|
+
utf8_string_concat_literal (const utf8_string_t *string, const utf8_t *literal, size_t n, utf8_string_t *result);
|
|
110
|
+
|
|
111
|
+
extern int
|
|
112
|
+
utf8_string_view_concat_literal (const utf8_string_view_t view, const utf8_t *literal, size_t n, utf8_string_t *result);
|
|
113
|
+
|
|
114
|
+
extern int
|
|
115
|
+
utf8_string_compare (const utf8_string_t *string, const utf8_string_t *other);
|
|
116
|
+
|
|
117
|
+
extern int
|
|
118
|
+
utf8_string_view_compare (const utf8_string_view_t view, const utf8_string_view_t other);
|
|
119
|
+
|
|
120
|
+
extern int
|
|
121
|
+
utf8_string_compare_literal (const utf8_string_t *string, const utf8_t *literal, size_t n);
|
|
122
|
+
|
|
123
|
+
extern int
|
|
124
|
+
utf8_string_view_compare_literal (const utf8_string_view_t view, const utf8_t *literal, size_t n);
|
|
125
|
+
|
|
126
|
+
extern utf8_string_view_t
|
|
127
|
+
utf8_string_substring (const utf8_string_t *string, size_t start, size_t end);
|
|
128
|
+
|
|
129
|
+
extern utf8_string_view_t
|
|
130
|
+
utf8_string_view_substring (const utf8_string_view_t view, size_t start, size_t end);
|
|
131
|
+
|
|
132
|
+
extern int
|
|
133
|
+
utf8_string_substring_copy (const utf8_string_t *string, size_t start, size_t end, utf8_string_t *result);
|
|
134
|
+
|
|
135
|
+
extern int
|
|
136
|
+
utf8_string_view_substring_copy (const utf8_string_view_t view, size_t start, size_t end, utf8_string_t *result);
|
|
137
|
+
|
|
138
|
+
extern size_t
|
|
139
|
+
utf8_string_index_of_character (const utf8_string_t *string, size_t pos, utf8_t c);
|
|
140
|
+
|
|
141
|
+
extern size_t
|
|
142
|
+
utf8_string_view_index_of_character (const utf8_string_view_t view, size_t pos, utf8_t c);
|
|
143
|
+
|
|
144
|
+
extern size_t
|
|
145
|
+
utf8_string_last_index_of_character (const utf8_string_t *string, size_t pos, utf8_t c);
|
|
146
|
+
|
|
147
|
+
extern size_t
|
|
148
|
+
utf8_string_view_last_index_of_character (const utf8_string_view_t view, size_t pos, utf8_t c);
|