bare-url 1.1.2 → 1.2.1

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 (50) hide show
  1. package/binding.c +9 -5
  2. package/index.js +16 -9
  3. package/package.json +1 -1
  4. package/prebuilds/android-arm/bare-url.bare +0 -0
  5. package/prebuilds/android-arm64/bare-url.bare +0 -0
  6. package/prebuilds/android-ia32/bare-url.bare +0 -0
  7. package/prebuilds/android-x64/bare-url.bare +0 -0
  8. package/prebuilds/darwin-arm64/bare-url.bare +0 -0
  9. package/prebuilds/darwin-x64/bare-url.bare +0 -0
  10. package/prebuilds/ios-arm64/bare-url.bare +0 -0
  11. package/prebuilds/ios-arm64-simulator/bare-url.bare +0 -0
  12. package/prebuilds/ios-x64-simulator/bare-url.bare +0 -0
  13. package/prebuilds/linux-arm64/bare-url.bare +0 -0
  14. package/prebuilds/linux-x64/bare-url.bare +0 -0
  15. package/prebuilds/win32-x64/bare-url.bare +0 -0
  16. package/vendor/liburl/src/parse.h +4 -2
  17. package/vendor/libutf/CMakeLists.txt +23 -6
  18. package/vendor/libutf/include/utf/string.h +44 -18
  19. package/vendor/libutf/include/utf.h +87 -0
  20. package/vendor/libutf/src/ascii/validate.c +47 -0
  21. package/vendor/libutf/src/endianness.c +1 -1
  22. package/vendor/libutf/src/latin1/convert-to-utf16.c +37 -0
  23. package/vendor/libutf/src/latin1/convert-to-utf32.c +34 -0
  24. package/vendor/libutf/src/latin1/convert-to-utf8.c +58 -0
  25. package/vendor/libutf/src/latin1/length-from-utf16.c +26 -0
  26. package/vendor/libutf/src/latin1/length-from-utf32.c +26 -0
  27. package/vendor/libutf/src/latin1/length-from-utf8.c +34 -0
  28. package/vendor/libutf/src/utf16/convert-to-latin1.c +41 -0
  29. package/vendor/libutf/src/utf16/convert-to-utf32.c +56 -0
  30. package/vendor/libutf/src/utf16/{utf8-convert.c → convert-to-utf8.c} +1 -3
  31. package/vendor/libutf/src/utf16/length-from-latin1.c +26 -0
  32. package/vendor/libutf/src/utf16/length-from-utf32.c +33 -0
  33. package/vendor/libutf/src/{utf8/utf16-length.c → utf16/length-from-utf8.c} +0 -1
  34. package/vendor/libutf/src/utf16/validate.c +1 -1
  35. package/vendor/libutf/src/utf32/convert-to-latin1.c +40 -0
  36. package/vendor/libutf/src/utf32/convert-to-utf16.c +56 -0
  37. package/vendor/libutf/src/utf32/convert-to-utf8.c +71 -0
  38. package/vendor/libutf/src/utf32/length-from-latin1.c +26 -0
  39. package/vendor/libutf/src/utf32/length-from-utf16.c +35 -0
  40. package/vendor/libutf/src/utf32/length-from-utf8.c +35 -0
  41. package/vendor/libutf/src/utf32/validate.c +39 -0
  42. package/vendor/libutf/src/utf8/convert-to-latin1.c +70 -0
  43. package/vendor/libutf/src/utf8/{utf16-convert.c → convert-to-utf16.c} +10 -5
  44. package/vendor/libutf/src/utf8/convert-to-utf32.c +110 -0
  45. package/vendor/libutf/src/utf8/length-from-latin1.c +32 -0
  46. package/vendor/libutf/src/{utf16/utf8-length.c → utf8/length-from-utf16.c} +1 -2
  47. package/vendor/libutf/src/utf8/length-from-utf32.c +35 -0
  48. package/vendor/libutf/src/utf8/string.c +2 -1
  49. package/vendor/libutf/src/utf8/validate.c +9 -9
  50. /package/vendor/libutf/{include/utf → src}/endianness.h +0 -0
package/binding.c CHANGED
@@ -14,13 +14,17 @@ static js_value_t *
14
14
  bare_url_parse (js_env_t *env, js_callback_info_t *info) {
15
15
  int err;
16
16
 
17
- size_t argc = 3;
18
- js_value_t *argv[3];
17
+ size_t argc = 4;
18
+ js_value_t *argv[4];
19
19
 
20
20
  err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
21
21
  assert(err == 0);
22
22
 
23
- assert(argc == 3);
23
+ assert(argc == 4);
24
+
25
+ bool should_throw;
26
+ err = js_get_value_bool(env, argv[3], &should_throw);
27
+ assert(err == 0);
24
28
 
25
29
  bool has_base;
26
30
  err = js_is_string(env, argv[1], &has_base);
@@ -45,7 +49,7 @@ bare_url_parse (js_env_t *env, js_callback_info_t *info) {
45
49
  if (err < 0) {
46
50
  url_destroy(&base);
47
51
 
48
- js_throw_error(env, NULL, "Invalid base URL");
52
+ if (should_throw) js_throw_error(env, NULL, "Invalid base URL");
49
53
 
50
54
  return NULL;
51
55
  }
@@ -72,7 +76,7 @@ bare_url_parse (js_env_t *env, js_callback_info_t *info) {
72
76
  url_destroy(&base);
73
77
  url_destroy(&url);
74
78
 
75
- js_throw_error(env, NULL, "Invalid URL");
79
+ if (should_throw) js_throw_error(env, NULL, "Invalid URL");
76
80
 
77
81
  return NULL;
78
82
  }
package/index.js CHANGED
@@ -11,14 +11,16 @@ const URL = module.exports = exports = class URL {
11
11
  binding.tag(this)
12
12
  }
13
13
 
14
- constructor (href, base) {
15
- if (typeof href !== 'string') throw errors.INVALID_URL()
14
+ constructor (input, base, opts = {}) {
15
+ if (arguments.length === 0) throw errors.INVALID_URL()
16
16
 
17
- if (base && typeof base !== 'string') base = base.href
17
+ input = `${input}`
18
+
19
+ if (base !== undefined) base = `${base}`
18
20
 
19
21
  this._components = new Uint32Array(8)
20
22
 
21
- this._parse(href, base)
23
+ this._parse(input, base, opts.throw !== false)
22
24
  }
23
25
 
24
26
  // https://url.spec.whatwg.org/#dom-url-href
@@ -208,9 +210,9 @@ const URL = module.exports = exports = class URL {
208
210
  return this._slice(0, start) + replacement + this._slice(end)
209
211
  }
210
212
 
211
- _parse (href, base) {
213
+ _parse (href, base, shouldThrow) {
212
214
  try {
213
- this._href = binding.parse(String(href), base ? String(base) : null, this._components)
215
+ this._href = binding.parse(String(href), base ? String(base) : null, this._components, shouldThrow)
214
216
  } catch (err) {
215
217
  safetyCatch(err)
216
218
 
@@ -220,7 +222,7 @@ const URL = module.exports = exports = class URL {
220
222
 
221
223
  _update (href) {
222
224
  try {
223
- this._parse(href, null)
225
+ this._parse(href, null, true)
224
226
  } catch (err) {
225
227
  safetyCatch(err)
226
228
  }
@@ -253,8 +255,13 @@ exports.isURL = function isURL (value) {
253
255
  return false
254
256
  }
255
257
 
256
- exports.canParse = function canParse (href, base) {
257
- return binding.canParse(String(href), base ? String(base) : null)
258
+ exports.parse = function parse (input, base) {
259
+ const url = new URL(input, base, { throw: false })
260
+ return url.href ? url : null
261
+ }
262
+
263
+ exports.canParse = function canParse (input, base) {
264
+ return binding.canParse(String(input), base ? String(base) : null)
258
265
  }
259
266
 
260
267
  exports.fileURLToPath = function fileURLToPath (url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-url",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "WHATWG URL implementation for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [
Binary file
Binary file
Binary file
Binary file
@@ -882,8 +882,10 @@ url__parse (url_t *url, const utf8_string_view_t input, const url_t *base) {
882
882
  utf8_string_view_t host = url_get_host(base);
883
883
 
884
884
  if (!utf8_string_view_empty(host)) {
885
- err = utf8_string_append_literal(&url->href, (utf8_t *) "//", 2);
886
- if (err < 0) goto err;
885
+ if (url->type == url_type_opaque) {
886
+ err = utf8_string_append_literal(&url->href, (utf8_t *) "//", 2);
887
+ if (err < 0) goto err;
888
+ }
887
889
 
888
890
  utf8_string_view_t username = url_get_username(base);
889
891
 
@@ -15,17 +15,33 @@ target_sources(
15
15
  utf
16
16
  INTERFACE
17
17
  include/utf.h
18
- include/utf/endianness.h
19
18
  include/utf/string.h
20
19
  PRIVATE
21
20
  src/endianness.c
22
- src/utf8/utf16-convert.c
23
- src/utf8/utf16-length.c
24
- src/utf8/validate.c
21
+ src/endianness.h
22
+ src/ascii/validate.c
23
+ src/utf8/convert-to-latin1.c
24
+ src/utf8/convert-to-utf16.c
25
+ src/utf8/convert-to-utf32.c
26
+ src/utf8/length-from-latin1.c
27
+ src/utf8/length-from-utf16.c
28
+ src/utf8/length-from-utf32.c
25
29
  src/utf8/string.c
26
- src/utf16/utf8-convert.c
27
- src/utf16/utf8-length.c
30
+ src/utf8/validate.c
31
+ src/utf16/convert-to-latin1.c
32
+ src/utf16/convert-to-utf8.c
33
+ src/utf16/convert-to-utf32.c
34
+ src/utf16/length-from-latin1.c
35
+ src/utf16/length-from-utf8.c
36
+ src/utf16/length-from-utf32.c
28
37
  src/utf16/validate.c
38
+ src/utf32/convert-to-latin1.c
39
+ src/utf32/convert-to-utf8.c
40
+ src/utf32/convert-to-utf16.c
41
+ src/utf32/length-from-latin1.c
42
+ src/utf32/length-from-utf8.c
43
+ src/utf32/length-from-utf16.c
44
+ src/utf32/validate.c
29
45
  )
30
46
 
31
47
  target_include_directories(
@@ -72,5 +88,6 @@ install(DIRECTORY include/utf DESTINATION include)
72
88
 
73
89
  if(PROJECT_IS_TOP_LEVEL)
74
90
  enable_testing()
91
+
75
92
  add_subdirectory(test)
76
93
  endif()
@@ -24,7 +24,10 @@ typedef struct utf8_string_view_s utf8_string_view_t;
24
24
  struct utf8_string_s {
25
25
  utf8_t *data;
26
26
  size_t len;
27
- size_t cap;
27
+ union {
28
+ size_t cap;
29
+ utf8_t buf[8];
30
+ };
28
31
  };
29
32
 
30
33
  struct utf8_string_view_s {
@@ -34,9 +37,8 @@ struct utf8_string_view_s {
34
37
 
35
38
  inline void
36
39
  utf8_string_init (utf8_string_t *string) {
40
+ string->data = string->buf;
37
41
  string->len = 0;
38
- string->cap = 0;
39
- string->data = NULL;
40
42
  }
41
43
 
42
44
  inline utf8_string_view_t
@@ -46,41 +48,65 @@ utf8_string_view_init (const utf8_t *data, size_t len) {
46
48
 
47
49
  inline void
48
50
  utf8_string_destroy (utf8_string_t *string) {
49
- free(string->data);
51
+ if (string->data != string->buf) free(string->data);
50
52
  }
51
53
 
52
54
  inline int
53
55
  utf8_string_reserve (utf8_string_t *string, size_t len) {
54
- size_t cap = string->cap;
56
+ size_t cap = string->data == string->buf ? sizeof(string->buf) : string->cap;
55
57
 
56
- if (len < cap) return 0;
58
+ if (len <= cap) return 0;
57
59
 
58
- if (cap == 0) cap = sizeof(utf8_string_t) - 1;
60
+ // https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
61
+ len--;
62
+ len |= len >> 1;
63
+ len |= len >> 2;
64
+ len |= len >> 4;
65
+ len |= len >> 8;
66
+ len |= len >> 16;
67
+ if (sizeof(len) == 8) len |= len >> 32;
68
+ len++;
59
69
 
60
- while (cap < len) {
61
- cap = cap * 2 + 1;
62
- }
70
+ cap = len;
71
+
72
+ utf8_t *data;
63
73
 
64
- void *data = realloc(string->data, cap);
74
+ if (string->data == string->buf) {
75
+ data = (utf8_t *) malloc(cap);
76
+
77
+ memcpy(data, string->data, string->len);
78
+ } else {
79
+ data = (utf8_t *) realloc(string->data, cap);
80
+ }
65
81
 
66
82
  if (data == NULL) return -1;
67
83
 
68
- string->cap = cap;
69
84
  string->data = data;
85
+ string->cap = cap;
70
86
 
71
87
  return 0;
72
88
  }
73
89
 
74
90
  inline int
75
91
  utf8_string_shrink_to_fit (utf8_string_t *string) {
76
- size_t cap = string->len + 1;
92
+ if (string->data == string->buf) return 0;
77
93
 
78
- void *data = realloc(string->data, cap);
94
+ size_t cap = string->len;
79
95
 
80
- if (data == NULL) return -1;
96
+ if (cap <= sizeof(string->buf)) {
97
+ memcpy(string->buf, string->data, cap);
81
98
 
82
- string->cap = cap;
83
- string->data = data;
99
+ free(string->data);
100
+
101
+ string->data = string->buf;
102
+ } else {
103
+ utf8_t *data = (utf8_t *) realloc(string->data, cap);
104
+
105
+ if (data == NULL) return -1;
106
+
107
+ string->data = data;
108
+ string->cap = cap;
109
+ }
84
110
 
85
111
  return 0;
86
112
  }
@@ -96,7 +122,7 @@ utf8_string_clear (utf8_string_t *string) {
96
122
  }
97
123
 
98
124
  inline bool
99
- utf8_string_empty (utf8_string_t *string) {
125
+ utf8_string_empty (const utf8_string_t *string) {
100
126
  return string->len == 0;
101
127
  }
102
128
 
@@ -11,6 +11,9 @@ extern "C" {
11
11
 
12
12
  typedef uint_least8_t utf8_t;
13
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;
14
17
 
15
18
  /**
16
19
  * UTF-8
@@ -22,9 +25,21 @@ utf8_validate (const utf8_t *data, size_t len);
22
25
  size_t
23
26
  utf8_length_from_utf16le (const utf16_t *data, size_t len);
24
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
+
25
34
  size_t
26
35
  utf8_convert_to_utf16le (const utf8_t *data, size_t len, utf16_t *result);
27
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
+
28
43
  /**
29
44
  * UTF-16
30
45
  */
@@ -35,9 +50,81 @@ utf16le_validate (const utf16_t *data, size_t len);
35
50
  size_t
36
51
  utf16_length_from_utf8 (const utf8_t *data, size_t len);
37
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
+
38
59
  size_t
39
60
  utf16le_convert_to_utf8 (const utf16_t *data, size_t len, utf8_t *result);
40
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
+
41
128
  #ifdef __cplusplus
42
129
  }
43
130
  #endif
@@ -0,0 +1,47 @@
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,7 +1,7 @@
1
1
  #include <stdbool.h>
2
2
  #include <stdint.h>
3
3
 
4
- #include "../include/utf/endianness.h"
4
+ #include "endianness.h"
5
5
 
6
6
  extern utf_endianness_t
7
7
  utf_endianness (void);
@@ -0,0 +1,37 @@
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
+ }
@@ -0,0 +1,34 @@
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
+ }
@@ -0,0 +1,58 @@
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
+ }
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,26 @@
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
+ }