bare-buffer 2.5.9 → 2.5.11

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.
Files changed (55) hide show
  1. package/CMakeLists.txt +4 -11
  2. package/package.json +3 -8
  3. package/prebuilds/android-arm/bare-buffer.bare +0 -0
  4. package/prebuilds/android-arm64/bare-buffer.bare +0 -0
  5. package/prebuilds/android-ia32/bare-buffer.bare +0 -0
  6. package/prebuilds/android-x64/bare-buffer.bare +0 -0
  7. package/prebuilds/darwin-arm64/bare-buffer.bare +0 -0
  8. package/prebuilds/darwin-x64/bare-buffer.bare +0 -0
  9. package/prebuilds/ios-arm64/bare-buffer.bare +0 -0
  10. package/prebuilds/ios-arm64-simulator/bare-buffer.bare +0 -0
  11. package/prebuilds/ios-x64-simulator/bare-buffer.bare +0 -0
  12. package/prebuilds/linux-arm64/bare-buffer.bare +0 -0
  13. package/prebuilds/linux-x64/bare-buffer.bare +0 -0
  14. package/prebuilds/win32-arm64/bare-buffer.bare +0 -0
  15. package/prebuilds/win32-x64/bare-buffer.bare +0 -0
  16. package/vendor/libbase64/CMakeLists.txt +0 -70
  17. package/vendor/libbase64/include/base64.h +0 -22
  18. package/vendor/libbase64/src/base64.c +0 -107
  19. package/vendor/libhex/CMakeLists.txt +0 -71
  20. package/vendor/libhex/include/hex.h +0 -22
  21. package/vendor/libhex/src/hex.c +0 -67
  22. package/vendor/libutf/CMakeLists.txt +0 -93
  23. package/vendor/libutf/include/utf/string.h +0 -786
  24. package/vendor/libutf/include/utf.h +0 -132
  25. package/vendor/libutf/src/ascii/validate.c +0 -47
  26. package/vendor/libutf/src/endianness.c +0 -19
  27. package/vendor/libutf/src/endianness.h +0 -54
  28. package/vendor/libutf/src/latin1/convert-to-utf16.c +0 -37
  29. package/vendor/libutf/src/latin1/convert-to-utf32.c +0 -34
  30. package/vendor/libutf/src/latin1/convert-to-utf8.c +0 -58
  31. package/vendor/libutf/src/latin1/length-from-utf16.c +0 -26
  32. package/vendor/libutf/src/latin1/length-from-utf32.c +0 -26
  33. package/vendor/libutf/src/latin1/length-from-utf8.c +0 -34
  34. package/vendor/libutf/src/utf16/convert-to-latin1.c +0 -41
  35. package/vendor/libutf/src/utf16/convert-to-utf32.c +0 -56
  36. package/vendor/libutf/src/utf16/convert-to-utf8.c +0 -75
  37. package/vendor/libutf/src/utf16/length-from-latin1.c +0 -26
  38. package/vendor/libutf/src/utf16/length-from-utf32.c +0 -33
  39. package/vendor/libutf/src/utf16/length-from-utf8.c +0 -38
  40. package/vendor/libutf/src/utf16/validate.c +0 -53
  41. package/vendor/libutf/src/utf32/convert-to-latin1.c +0 -40
  42. package/vendor/libutf/src/utf32/convert-to-utf16.c +0 -56
  43. package/vendor/libutf/src/utf32/convert-to-utf8.c +0 -71
  44. package/vendor/libutf/src/utf32/length-from-latin1.c +0 -26
  45. package/vendor/libutf/src/utf32/length-from-utf16.c +0 -35
  46. package/vendor/libutf/src/utf32/length-from-utf8.c +0 -35
  47. package/vendor/libutf/src/utf32/validate.c +0 -39
  48. package/vendor/libutf/src/utf8/convert-to-latin1.c +0 -70
  49. package/vendor/libutf/src/utf8/convert-to-utf16.c +0 -95
  50. package/vendor/libutf/src/utf8/convert-to-utf32.c +0 -110
  51. package/vendor/libutf/src/utf8/length-from-latin1.c +0 -32
  52. package/vendor/libutf/src/utf8/length-from-utf16.c +0 -44
  53. package/vendor/libutf/src/utf8/length-from-utf32.c +0 -35
  54. package/vendor/libutf/src/utf8/string.c +0 -149
  55. package/vendor/libutf/src/utf8/validate.c +0 -107
@@ -1,132 +0,0 @@
1
- #ifndef UTF_H
2
- #define UTF_H
3
-
4
- #ifdef __cplusplus
5
- extern "C" {
6
- #endif
7
-
8
- #include <stdbool.h>
9
- #include <stddef.h>
10
- #include <stdint.h>
11
-
12
- typedef uint_least8_t utf8_t;
13
- typedef uint_least16_t utf16_t;
14
- typedef uint_least32_t utf32_t;
15
- typedef uint_least8_t latin1_t;
16
- typedef uint_least8_t ascii_t;
17
-
18
- /**
19
- * UTF-8
20
- */
21
-
22
- bool
23
- utf8_validate (const utf8_t *data, size_t len);
24
-
25
- size_t
26
- utf8_length_from_utf16le (const utf16_t *data, size_t len);
27
-
28
- size_t
29
- utf8_length_from_utf32 (const utf32_t *data, size_t len);
30
-
31
- size_t
32
- utf8_length_from_latin1 (const latin1_t *data, size_t len);
33
-
34
- size_t
35
- utf8_convert_to_utf16le (const utf8_t *data, size_t len, utf16_t *result);
36
-
37
- size_t
38
- utf8_convert_to_utf32 (const utf8_t *data, size_t len, utf32_t *result);
39
-
40
- size_t
41
- utf8_convert_to_latin1 (const utf8_t *data, size_t len, latin1_t *result);
42
-
43
- /**
44
- * UTF-16
45
- */
46
-
47
- bool
48
- utf16le_validate (const utf16_t *data, size_t len);
49
-
50
- size_t
51
- utf16_length_from_utf8 (const utf8_t *data, size_t len);
52
-
53
- size_t
54
- utf16_length_from_utf32 (const utf32_t *data, size_t len);
55
-
56
- size_t
57
- utf16_length_from_latin1 (const latin1_t *data, size_t len);
58
-
59
- size_t
60
- utf16le_convert_to_utf8 (const utf16_t *data, size_t len, utf8_t *result);
61
-
62
- size_t
63
- utf16le_convert_to_utf32 (const utf16_t *data, size_t len, utf32_t *result);
64
-
65
- size_t
66
- utf16le_convert_to_latin1 (const utf16_t *data, size_t len, latin1_t *result);
67
-
68
- /**
69
- * UTF-32
70
- */
71
-
72
- bool
73
- utf32_validate (const utf32_t *data, size_t len);
74
-
75
- size_t
76
- utf32_length_from_utf8 (const utf8_t *data, size_t len);
77
-
78
- size_t
79
- utf32_length_from_utf16le (const utf16_t *data, size_t len);
80
-
81
- size_t
82
- utf32_length_from_latin1 (const latin1_t *data, size_t len);
83
-
84
- size_t
85
- utf32_convert_to_utf8 (const utf32_t *data, size_t len, utf8_t *result);
86
-
87
- size_t
88
- utf32_convert_to_utf16le (const utf32_t *data, size_t len, utf16_t *result);
89
-
90
- size_t
91
- utf32_convert_to_latin1 (const utf32_t *data, size_t len, latin1_t *result);
92
-
93
- /**
94
- * Latin-1
95
- */
96
-
97
- size_t
98
- latin1_length_from_utf8 (const utf8_t *data, size_t len);
99
-
100
- size_t
101
- latin1_length_from_utf16le (const utf16_t *data, size_t len);
102
-
103
- size_t
104
- latin1_length_from_utf32 (const utf32_t *data, size_t len);
105
-
106
- size_t
107
- latin1_convert_to_utf8 (const latin1_t *data, size_t len, utf8_t *result);
108
-
109
- size_t
110
- latin1_convert_to_utf16le (const latin1_t *data, size_t len, utf16_t *result);
111
-
112
- size_t
113
- latin1_convert_to_utf32 (const latin1_t *data, size_t len, utf32_t *result);
114
-
115
- /**
116
- * ASCII
117
- */
118
-
119
- bool
120
- ascii_validate (const ascii_t *data, size_t len);
121
-
122
- /**
123
- * Strings
124
- */
125
-
126
- #include <utf/string.h>
127
-
128
- #ifdef __cplusplus
129
- }
130
- #endif
131
-
132
- #endif // UTF_H
@@ -1,47 +0,0 @@
1
- #include <stdbool.h>
2
- #include <stddef.h>
3
- #include <stdint.h>
4
- #include <string.h>
5
-
6
- #include "../../include/utf.h"
7
-
8
- /**
9
- * Modified from https://github.com/simdutf/simdutf
10
- *
11
- * Copyright 2020 The simdutf authors
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
-
26
- bool
27
- ascii_validate (const ascii_t *data, size_t len) {
28
- uint64_t pos = 0;
29
-
30
- for (; pos + 16 <= len; pos += 16) {
31
- uint64_t v1;
32
- memcpy(&v1, data + pos, sizeof(uint64_t));
33
- uint64_t v2;
34
- memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
35
- uint64_t v = v1 | v2;
36
- if ((v & 0x8080808080808080) != 0) {
37
- return false;
38
- }
39
- }
40
- for (; pos < len; pos++) {
41
- if (data[pos] >= 0b10000000) {
42
- return false;
43
- }
44
- }
45
-
46
- return true;
47
- }
@@ -1,19 +0,0 @@
1
- #include <stdbool.h>
2
- #include <stdint.h>
3
-
4
- #include "endianness.h"
5
-
6
- extern utf_endianness_t
7
- utf_endianness (void);
8
-
9
- extern bool
10
- utf_is_le (void);
11
-
12
- extern bool
13
- utf_is_be (void);
14
-
15
- extern uint16_t
16
- utf_swap_uint16 (uint16_t n);
17
-
18
- extern uint32_t
19
- utf_swap_uint32 (uint32_t n);
@@ -1,54 +0,0 @@
1
- #ifndef UTF_ENDIANNESS_H
2
- #define UTF_ENDIANNESS_H
3
-
4
- #ifdef __cplusplus
5
- extern "C" {
6
- #endif
7
-
8
- #include <stdbool.h>
9
- #include <stdint.h>
10
-
11
- typedef enum {
12
- utf_le,
13
- utf_be
14
- } utf_endianness_t;
15
-
16
- inline utf_endianness_t
17
- utf_endianness (void) {
18
- const union {
19
- uint8_t u8[2];
20
- uint16_t u16;
21
- } byte_order = {{1, 0}};
22
-
23
- return byte_order.u16 == 1 ? utf_le : utf_be;
24
- }
25
-
26
- inline bool
27
- utf_is_le (void) {
28
- return utf_endianness() == utf_le;
29
- }
30
-
31
- inline bool
32
- utf_is_be (void) {
33
- return utf_endianness() == utf_be;
34
- }
35
-
36
- inline uint16_t
37
- utf_swap_uint16 (uint16_t n) {
38
- return ((n & 0x00ff) << 8) |
39
- ((n & 0xff00) >> 8);
40
- }
41
-
42
- inline uint32_t
43
- utf_swap_uint32 (uint32_t n) {
44
- return ((n & 0x000000ff) << 24) |
45
- ((n & 0x0000ff00) << 8) |
46
- ((n & 0x00ff0000) >> 8) |
47
- ((n & 0xff000000) >> 24);
48
- }
49
-
50
- #ifdef __cplusplus
51
- }
52
- #endif
53
-
54
- #endif // UTF_ENDIANNESS_H
@@ -1,37 +0,0 @@
1
- #include <stddef.h>
2
- #include <stdint.h>
3
- #include <string.h>
4
-
5
- #include "../../include/utf.h"
6
- #include "../endianness.h"
7
-
8
- /**
9
- * Modified from https://github.com/simdutf/simdutf
10
- *
11
- * Copyright 2020 The simdutf authors
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
-
26
- size_t
27
- latin1_convert_to_utf16le (const latin1_t *data, size_t len, utf16_t *result) {
28
- size_t pos = 0;
29
- utf16_t *start = result;
30
-
31
- while (pos < len) {
32
- *result++ = utf_is_be() ? utf_swap_uint16(data[pos]) : data[pos];
33
- pos++;
34
- }
35
-
36
- return result - start;
37
- }
@@ -1,34 +0,0 @@
1
- #include <stddef.h>
2
- #include <stdint.h>
3
- #include <string.h>
4
-
5
- #include "../../include/utf.h"
6
-
7
- /**
8
- * Modified from https://github.com/simdutf/simdutf
9
- *
10
- * Copyright 2020 The simdutf authors
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
-
25
- size_t
26
- latin1_convert_to_utf32 (const latin1_t *data, size_t len, utf32_t *result) {
27
- utf32_t *start = result;
28
-
29
- for (size_t i = 0; i < len; i++) {
30
- *result++ = data[i];
31
- }
32
-
33
- return result - start;
34
- }
@@ -1,58 +0,0 @@
1
- #include <stddef.h>
2
- #include <stdint.h>
3
- #include <string.h>
4
-
5
- #include "../../include/utf.h"
6
-
7
- /**
8
- * Modified from https://github.com/simdutf/simdutf
9
- *
10
- * Copyright 2020 The simdutf authors
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
-
25
- size_t
26
- latin1_convert_to_utf8 (const latin1_t *data, size_t len, utf8_t *result) {
27
- size_t pos = 0;
28
- utf8_t *start = result;
29
-
30
- while (pos < len) {
31
- if (pos + 16 <= len) {
32
- uint64_t v1;
33
- memcpy(&v1, data + pos, sizeof(uint64_t));
34
- uint64_t v2;
35
- memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
36
- uint64_t v = v1 | v2;
37
- if ((v & 0x8080808080808080) == 0) {
38
- size_t final_pos = pos + 16;
39
- while (pos < final_pos) {
40
- *result++ = data[pos];
41
- pos++;
42
- }
43
- continue;
44
- }
45
- }
46
- unsigned char byte = data[pos];
47
- if ((byte & 0x80) == 0) {
48
- *result++ = byte;
49
- pos++;
50
- } else {
51
- *result++ = (byte >> 6) | 0b11000000;
52
- *result++ = (byte & 0b111111) | 0b10000000;
53
- pos++;
54
- }
55
- }
56
-
57
- return result - start;
58
- }
@@ -1,26 +0,0 @@
1
- #include <stddef.h>
2
-
3
- #include "../../include/utf.h"
4
-
5
- /**
6
- * Modified from https://github.com/simdutf/simdutf
7
- *
8
- * Copyright 2020 The simdutf authors
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
-
23
- size_t
24
- latin1_length_from_utf16le (const utf16_t *data, size_t len) {
25
- return len;
26
- }
@@ -1,26 +0,0 @@
1
- #include <stddef.h>
2
-
3
- #include "../../include/utf.h"
4
-
5
- /**
6
- * Modified from https://github.com/simdutf/simdutf
7
- *
8
- * Copyright 2020 The simdutf authors
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
-
23
- size_t
24
- latin1_length_from_utf32 (const utf32_t *data, size_t len) {
25
- return len;
26
- }
@@ -1,34 +0,0 @@
1
- #include <stddef.h>
2
-
3
- #include "../../include/utf.h"
4
-
5
- /**
6
- * Modified from https://github.com/simdutf/simdutf
7
- *
8
- * Copyright 2020 The simdutf authors
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
-
23
- size_t
24
- latin1_length_from_utf8 (const utf8_t *data, size_t len) {
25
- size_t counter = 0;
26
-
27
- for (size_t i = 0; i < len; i++) {
28
- if ((int8_t) data[i] > -65) {
29
- counter++;
30
- }
31
- }
32
-
33
- return counter;
34
- }
@@ -1,41 +0,0 @@
1
- #include <stddef.h>
2
- #include <stdint.h>
3
-
4
- #include "../../include/utf.h"
5
- #include "../endianness.h"
6
-
7
- /**
8
- * Modified from https://github.com/simdutf/simdutf
9
- *
10
- * Copyright 2020 The simdutf authors
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
-
25
- size_t
26
- utf16le_convert_to_latin1 (const utf16_t *data, size_t len, latin1_t *result) {
27
- size_t pos = 0;
28
- uint16_t word, overflow = 0;
29
- latin1_t *start = result;
30
-
31
- while (pos < len) {
32
- word = utf_is_be() ? utf_swap_uint16(data[pos]) : data[pos];
33
- overflow |= word;
34
- *result++ = word & 0xff;
35
- pos++;
36
- }
37
-
38
- if (overflow & 0xff00) return 0;
39
-
40
- return result - start;
41
- }
@@ -1,56 +0,0 @@
1
- #include <stddef.h>
2
- #include <stdint.h>
3
-
4
- #include "../../include/utf.h"
5
- #include "../endianness.h"
6
-
7
- /**
8
- * Modified from https://github.com/simdutf/simdutf
9
- *
10
- * Copyright 2020 The simdutf authors
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
-
25
- size_t
26
- utf16le_convert_to_utf32 (const utf16_t *data, size_t len, utf32_t *result) {
27
- size_t pos = 0;
28
- uint16_t word, diff;
29
- utf32_t *start = result;
30
-
31
- while (pos < len) {
32
- word = utf_is_be() ? utf_swap_uint16(data[pos]) : data[pos];
33
- if ((word & 0xf800) != 0xd800) {
34
- *result++ = word;
35
- pos++;
36
- } else {
37
- diff = word - 0xd800;
38
- if (diff > 0x3ff) {
39
- return 0;
40
- }
41
- if (pos + 1 >= len) {
42
- return 0;
43
- }
44
- word = utf_is_be() ? utf_swap_uint16(data[pos + 1]) : data[pos + 1];
45
- uint32_t value = (diff << 10) + (word - 0xdc00) + 0x10000;
46
- diff = word - 0xdc00;
47
- if (diff > 0x3ff) {
48
- return 0;
49
- }
50
- *result++ = value;
51
- pos += 2;
52
- }
53
- }
54
-
55
- return result - start;
56
- }
@@ -1,75 +0,0 @@
1
- #include <stddef.h>
2
- #include <stdint.h>
3
- #include <string.h>
4
-
5
- #include "../../include/utf.h"
6
- #include "../endianness.h"
7
-
8
- /**
9
- * Modified from https://github.com/simdutf/simdutf
10
- *
11
- * Copyright 2020 The simdutf authors
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
-
26
- size_t
27
- utf16le_convert_to_utf8 (const utf16_t *data, size_t len, utf8_t *result) {
28
- size_t pos = 0;
29
- uint16_t word, diff;
30
- utf8_t *start = result;
31
-
32
- while (pos < len) {
33
- if (pos + 4 <= len) {
34
- uint64_t v;
35
- memcpy(&v, data + pos, sizeof(uint64_t));
36
- if (utf_is_be()) v = (v >> 8) | (v << (64 - 8));
37
- if ((v & 0xff80ff80ff80ff80) == 0) {
38
- size_t final_pos = pos + 4;
39
- while (pos < final_pos) {
40
- *result++ = utf_is_be() ? utf_swap_uint16(data[pos]) : data[pos];
41
- pos++;
42
- }
43
- continue;
44
- }
45
- }
46
- word = utf_is_be() ? utf_swap_uint16(data[pos]) : data[pos];
47
- if ((word & 0xff80) == 0) {
48
- *result++ = word;
49
- pos++;
50
- } else if ((word & 0xf800) == 0) {
51
- *result++ = (word >> 6) | 0b11000000;
52
- *result++ = (word & 0b111111) | 0b10000000;
53
- pos++;
54
- } else if ((word & 0xf800) != 0xd800) {
55
- *result++ = (word >> 12) | 0b11100000;
56
- *result++ = ((word >> 6) & 0b111111) | 0b10000000;
57
- *result++ = (word & 0b111111) | 0b10000000;
58
- pos++;
59
- } else {
60
- diff = word - 0xd800;
61
- if (pos + 1 >= len) {
62
- return 0;
63
- }
64
- word = utf_is_be() ? utf_swap_uint16(data[pos + 1]) : data[pos + 1];
65
- uint32_t value = (diff << 10) + (word - 0xdc00) + 0x10000;
66
- *result++ = (value >> 18) | 0b11110000;
67
- *result++ = ((value >> 12) & 0b111111) | 0b10000000;
68
- *result++ = ((value >> 6) & 0b111111) | 0b10000000;
69
- *result++ = (value & 0b111111) | 0b10000000;
70
- pos += 2;
71
- }
72
- }
73
-
74
- return result - start;
75
- }
@@ -1,26 +0,0 @@
1
- #include <stddef.h>
2
-
3
- #include "../../include/utf.h"
4
-
5
- /**
6
- * Modified from https://github.com/simdutf/simdutf
7
- *
8
- * Copyright 2020 The simdutf authors
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
-
23
- size_t
24
- utf16_length_from_latin1 (const utf8_t *data, size_t len) {
25
- return len;
26
- }