react-native-quick-crypto 1.0.19 → 1.1.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 (561) hide show
  1. package/QuickCrypto.podspec +12 -38
  2. package/README.md +2 -0
  3. package/android/CMakeLists.txt +3 -0
  4. package/android/build.gradle +5 -1
  5. package/cpp/argon2/HybridArgon2.cpp +10 -3
  6. package/cpp/blake3/HybridBlake3.cpp +5 -3
  7. package/cpp/cipher/CCMCipher.cpp +29 -16
  8. package/cpp/cipher/CCMCipher.hpp +2 -4
  9. package/cpp/cipher/ChaCha20Cipher.cpp +14 -18
  10. package/cpp/cipher/ChaCha20Cipher.hpp +2 -4
  11. package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +34 -23
  12. package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +2 -4
  13. package/cpp/cipher/GCMCipher.cpp +14 -15
  14. package/cpp/cipher/HybridCipher.cpp +39 -36
  15. package/cpp/cipher/HybridCipher.hpp +17 -1
  16. package/cpp/cipher/HybridRsaCipher.cpp +74 -29
  17. package/cpp/cipher/OCBCipher.cpp +4 -3
  18. package/cpp/cipher/XChaCha20Poly1305Cipher.cpp +14 -13
  19. package/cpp/cipher/XSalsa20Cipher.cpp +72 -6
  20. package/cpp/cipher/XSalsa20Cipher.hpp +25 -3
  21. package/cpp/cipher/XSalsa20Poly1305Cipher.cpp +21 -25
  22. package/cpp/dh/HybridDiffieHellman.cpp +29 -0
  23. package/cpp/ec/HybridEcKeyPair.cpp +35 -33
  24. package/cpp/ec/HybridEcKeyPair.hpp +3 -7
  25. package/cpp/ecdh/HybridECDH.cpp +23 -0
  26. package/cpp/ed25519/HybridEdKeyPair.cpp +73 -117
  27. package/cpp/ed25519/HybridEdKeyPair.hpp +5 -9
  28. package/cpp/hash/HybridHash.cpp +5 -7
  29. package/cpp/hkdf/HybridHkdf.cpp +6 -4
  30. package/cpp/hmac/HybridHmac.cpp +4 -6
  31. package/cpp/kmac/HybridKmac.cpp +4 -4
  32. package/cpp/mldsa/HybridMlDsaKeyPair.cpp +37 -49
  33. package/cpp/mlkem/HybridMlKemKeyPair.cpp +39 -43
  34. package/cpp/pbkdf2/HybridPbkdf2.cpp +7 -8
  35. package/cpp/rsa/HybridRsaKeyPair.cpp +5 -8
  36. package/cpp/rsa/HybridRsaKeyPair.hpp +4 -7
  37. package/cpp/scrypt/HybridScrypt.cpp +6 -4
  38. package/cpp/sign/HybridSignHandle.cpp +25 -68
  39. package/cpp/sign/HybridVerifyHandle.cpp +23 -60
  40. package/cpp/utils/HybridUtils.cpp +213 -111
  41. package/cpp/utils/HybridUtils.hpp +9 -2
  42. package/cpp/utils/QuickCryptoUtils.hpp +72 -0
  43. package/deps/simdutf/LICENSE-APACHE +201 -0
  44. package/deps/simdutf/LICENSE-MIT +18 -0
  45. package/deps/simdutf/README.md +2782 -0
  46. package/deps/simdutf/include/simdutf/avx512.h +79 -0
  47. package/deps/simdutf/include/simdutf/base64_implementation.h +158 -0
  48. package/deps/simdutf/include/simdutf/base64_tables.h +887 -0
  49. package/deps/simdutf/include/simdutf/common_defs.h +186 -0
  50. package/deps/simdutf/include/simdutf/compiler_check.h +50 -0
  51. package/deps/simdutf/include/simdutf/constexpr_ptr.h +138 -0
  52. package/deps/simdutf/include/simdutf/encoding_types.h +189 -0
  53. package/deps/simdutf/include/simdutf/error.h +126 -0
  54. package/deps/simdutf/include/simdutf/implementation.h +7081 -0
  55. package/deps/simdutf/include/simdutf/internal/isadetection.h +325 -0
  56. package/deps/simdutf/include/simdutf/portability.h +285 -0
  57. package/deps/simdutf/include/simdutf/scalar/ascii.h +86 -0
  58. package/deps/simdutf/include/simdutf/scalar/atomic_util.h +105 -0
  59. package/deps/simdutf/include/simdutf/scalar/base64.h +911 -0
  60. package/deps/simdutf/include/simdutf/scalar/latin1.h +26 -0
  61. package/deps/simdutf/include/simdutf/scalar/latin1_to_utf16/latin1_to_utf16.h +52 -0
  62. package/deps/simdutf/include/simdutf/scalar/latin1_to_utf32/latin1_to_utf32.h +27 -0
  63. package/deps/simdutf/include/simdutf/scalar/latin1_to_utf8/latin1_to_utf8.h +191 -0
  64. package/deps/simdutf/include/simdutf/scalar/swap_bytes.h +35 -0
  65. package/deps/simdutf/include/simdutf/scalar/utf16.h +226 -0
  66. package/deps/simdutf/include/simdutf/scalar/utf16_to_latin1/utf16_to_latin1.h +108 -0
  67. package/deps/simdutf/include/simdutf/scalar/utf16_to_latin1/valid_utf16_to_latin1.h +40 -0
  68. package/deps/simdutf/include/simdutf/scalar/utf16_to_utf32/utf16_to_utf32.h +86 -0
  69. package/deps/simdutf/include/simdutf/scalar/utf16_to_utf32/valid_utf16_to_utf32.h +44 -0
  70. package/deps/simdutf/include/simdutf/scalar/utf16_to_utf8/utf16_to_utf8.h +295 -0
  71. package/deps/simdutf/include/simdutf/scalar/utf16_to_utf8/valid_utf16_to_utf8.h +91 -0
  72. package/deps/simdutf/include/simdutf/scalar/utf32.h +82 -0
  73. package/deps/simdutf/include/simdutf/scalar/utf32_to_latin1/utf32_to_latin1.h +68 -0
  74. package/deps/simdutf/include/simdutf/scalar/utf32_to_latin1/valid_utf32_to_latin1.h +67 -0
  75. package/deps/simdutf/include/simdutf/scalar/utf32_to_utf16/utf32_to_utf16.h +84 -0
  76. package/deps/simdutf/include/simdutf/scalar/utf32_to_utf16/valid_utf32_to_utf16.h +44 -0
  77. package/deps/simdutf/include/simdutf/scalar/utf32_to_utf8/utf32_to_utf8.h +142 -0
  78. package/deps/simdutf/include/simdutf/scalar/utf32_to_utf8/valid_utf32_to_utf8.h +72 -0
  79. package/deps/simdutf/include/simdutf/scalar/utf8.h +326 -0
  80. package/deps/simdutf/include/simdutf/scalar/utf8_to_latin1/utf8_to_latin1.h +225 -0
  81. package/deps/simdutf/include/simdutf/scalar/utf8_to_latin1/valid_utf8_to_latin1.h +87 -0
  82. package/deps/simdutf/include/simdutf/scalar/utf8_to_utf16/utf8_to_utf16.h +342 -0
  83. package/deps/simdutf/include/simdutf/scalar/utf8_to_utf16/valid_utf8_to_utf16.h +106 -0
  84. package/deps/simdutf/include/simdutf/scalar/utf8_to_utf32/utf8_to_utf32.h +299 -0
  85. package/deps/simdutf/include/simdutf/scalar/utf8_to_utf32/valid_utf8_to_utf32.h +83 -0
  86. package/deps/simdutf/include/simdutf/simdutf_version.h +26 -0
  87. package/deps/simdutf/include/simdutf.h +26 -0
  88. package/deps/simdutf/include/simdutf_c.h +342 -0
  89. package/deps/simdutf/src/arm64/arm_base64.cpp +791 -0
  90. package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf16.cpp +24 -0
  91. package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf32.cpp +24 -0
  92. package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf8.cpp +70 -0
  93. package/deps/simdutf/src/arm64/arm_convert_utf16_to_latin1.cpp +61 -0
  94. package/deps/simdutf/src/arm64/arm_convert_utf16_to_utf32.cpp +185 -0
  95. package/deps/simdutf/src/arm64/arm_convert_utf16_to_utf8.cpp +780 -0
  96. package/deps/simdutf/src/arm64/arm_convert_utf32_to_latin1.cpp +60 -0
  97. package/deps/simdutf/src/arm64/arm_convert_utf32_to_utf16.cpp +208 -0
  98. package/deps/simdutf/src/arm64/arm_convert_utf32_to_utf8.cpp +505 -0
  99. package/deps/simdutf/src/arm64/arm_convert_utf8_to_latin1.cpp +69 -0
  100. package/deps/simdutf/src/arm64/arm_convert_utf8_to_utf16.cpp +313 -0
  101. package/deps/simdutf/src/arm64/arm_convert_utf8_to_utf32.cpp +179 -0
  102. package/deps/simdutf/src/arm64/arm_find.cpp +199 -0
  103. package/deps/simdutf/src/arm64/arm_utf16fix.cpp +185 -0
  104. package/deps/simdutf/src/arm64/arm_validate_utf16.cpp +165 -0
  105. package/deps/simdutf/src/arm64/arm_validate_utf32le.cpp +65 -0
  106. package/deps/simdutf/src/arm64/implementation.cpp +1442 -0
  107. package/deps/simdutf/src/encoding_types.cpp +67 -0
  108. package/deps/simdutf/src/error.cpp +3 -0
  109. package/deps/simdutf/src/fallback/implementation.cpp +589 -0
  110. package/deps/simdutf/src/generic/ascii_validation.h +50 -0
  111. package/deps/simdutf/src/generic/base64.h +233 -0
  112. package/deps/simdutf/src/generic/base64lengths.h +63 -0
  113. package/deps/simdutf/src/generic/buf_block_reader.h +109 -0
  114. package/deps/simdutf/src/generic/find.h +75 -0
  115. package/deps/simdutf/src/generic/utf16/change_endianness.h +24 -0
  116. package/deps/simdutf/src/generic/utf16/count_code_points_bytemask.h +58 -0
  117. package/deps/simdutf/src/generic/utf16/to_well_formed.h +93 -0
  118. package/deps/simdutf/src/generic/utf16/utf32_length_from_utf16.h +15 -0
  119. package/deps/simdutf/src/generic/utf16/utf8_length_from_utf16.h +35 -0
  120. package/deps/simdutf/src/generic/utf16/utf8_length_from_utf16_bytemask.h +199 -0
  121. package/deps/simdutf/src/generic/utf16.h +73 -0
  122. package/deps/simdutf/src/generic/utf32.h +136 -0
  123. package/deps/simdutf/src/generic/utf8/utf16_length_from_utf8_bytemask.h +53 -0
  124. package/deps/simdutf/src/generic/utf8.h +92 -0
  125. package/deps/simdutf/src/generic/utf8_to_latin1/utf8_to_latin1.h +316 -0
  126. package/deps/simdutf/src/generic/utf8_to_latin1/valid_utf8_to_latin1.h +78 -0
  127. package/deps/simdutf/src/generic/utf8_to_utf16/utf8_to_utf16.h +332 -0
  128. package/deps/simdutf/src/generic/utf8_to_utf16/valid_utf8_to_utf16.h +74 -0
  129. package/deps/simdutf/src/generic/utf8_to_utf32/utf8_to_utf32.h +318 -0
  130. package/deps/simdutf/src/generic/utf8_to_utf32/valid_utf8_to_utf32.h +42 -0
  131. package/deps/simdutf/src/generic/utf8_validation/utf8_lookup4_algorithm.h +223 -0
  132. package/deps/simdutf/src/generic/utf8_validation/utf8_validator.h +84 -0
  133. package/deps/simdutf/src/generic/validate_utf16.h +164 -0
  134. package/deps/simdutf/src/generic/validate_utf32.h +99 -0
  135. package/deps/simdutf/src/haswell/avx2_base64.cpp +837 -0
  136. package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf16.cpp +28 -0
  137. package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf32.cpp +20 -0
  138. package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf8.cpp +83 -0
  139. package/deps/simdutf/src/haswell/avx2_convert_utf16_to_latin1.cpp +83 -0
  140. package/deps/simdutf/src/haswell/avx2_convert_utf16_to_utf32.cpp +210 -0
  141. package/deps/simdutf/src/haswell/avx2_convert_utf16_to_utf8.cpp +602 -0
  142. package/deps/simdutf/src/haswell/avx2_convert_utf32_to_latin1.cpp +116 -0
  143. package/deps/simdutf/src/haswell/avx2_convert_utf32_to_utf16.cpp +164 -0
  144. package/deps/simdutf/src/haswell/avx2_convert_utf32_to_utf8.cpp +569 -0
  145. package/deps/simdutf/src/haswell/avx2_convert_utf8_to_latin1.cpp +60 -0
  146. package/deps/simdutf/src/haswell/avx2_convert_utf8_to_utf16.cpp +195 -0
  147. package/deps/simdutf/src/haswell/avx2_convert_utf8_to_utf32.cpp +135 -0
  148. package/deps/simdutf/src/haswell/avx2_utf16fix.cpp +173 -0
  149. package/deps/simdutf/src/haswell/avx2_validate_utf16.cpp +17 -0
  150. package/deps/simdutf/src/haswell/implementation.cpp +1447 -0
  151. package/deps/simdutf/src/icelake/icelake_ascii_validation.inl.cpp +19 -0
  152. package/deps/simdutf/src/icelake/icelake_base64.inl.cpp +630 -0
  153. package/deps/simdutf/src/icelake/icelake_common.inl.cpp +37 -0
  154. package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf16.inl.cpp +36 -0
  155. package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf32.inl.cpp +23 -0
  156. package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf8.inl.cpp +107 -0
  157. package/deps/simdutf/src/icelake/icelake_convert_utf16_to_latin1.inl.cpp +103 -0
  158. package/deps/simdutf/src/icelake/icelake_convert_utf16_to_utf32.inl.cpp +136 -0
  159. package/deps/simdutf/src/icelake/icelake_convert_utf16_to_utf8.inl.cpp +206 -0
  160. package/deps/simdutf/src/icelake/icelake_convert_utf32_to_latin1.inl.cpp +74 -0
  161. package/deps/simdutf/src/icelake/icelake_convert_utf32_to_utf16.inl.cpp +338 -0
  162. package/deps/simdutf/src/icelake/icelake_convert_utf32_to_utf8.inl.cpp +574 -0
  163. package/deps/simdutf/src/icelake/icelake_convert_utf8_to_latin1.inl.cpp +104 -0
  164. package/deps/simdutf/src/icelake/icelake_convert_utf8_to_utf16.inl.cpp +75 -0
  165. package/deps/simdutf/src/icelake/icelake_convert_valid_utf8_to_latin1.inl.cpp +69 -0
  166. package/deps/simdutf/src/icelake/icelake_find.inl.cpp +146 -0
  167. package/deps/simdutf/src/icelake/icelake_from_utf8.inl.cpp +266 -0
  168. package/deps/simdutf/src/icelake/icelake_from_valid_utf8.inl.cpp +136 -0
  169. package/deps/simdutf/src/icelake/icelake_macros.inl.cpp +143 -0
  170. package/deps/simdutf/src/icelake/icelake_utf16fix.cpp +138 -0
  171. package/deps/simdutf/src/icelake/icelake_utf32_validation.inl.cpp +63 -0
  172. package/deps/simdutf/src/icelake/icelake_utf8_common.inl.cpp +753 -0
  173. package/deps/simdutf/src/icelake/icelake_utf8_length_from_utf16.inl.cpp +269 -0
  174. package/deps/simdutf/src/icelake/icelake_utf8_validation.inl.cpp +116 -0
  175. package/deps/simdutf/src/icelake/implementation.cpp +1903 -0
  176. package/deps/simdutf/src/implementation.cpp +2526 -0
  177. package/deps/simdutf/src/lasx/implementation.cpp +1531 -0
  178. package/deps/simdutf/src/lasx/lasx_base64.cpp +695 -0
  179. package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf16.cpp +76 -0
  180. package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf32.cpp +55 -0
  181. package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf8.cpp +65 -0
  182. package/deps/simdutf/src/lasx/lasx_convert_utf16_to_latin1.cpp +64 -0
  183. package/deps/simdutf/src/lasx/lasx_convert_utf16_to_utf32.cpp +183 -0
  184. package/deps/simdutf/src/lasx/lasx_convert_utf16_to_utf8.cpp +550 -0
  185. package/deps/simdutf/src/lasx/lasx_convert_utf32_to_latin1.cpp +73 -0
  186. package/deps/simdutf/src/lasx/lasx_convert_utf32_to_utf16.cpp +218 -0
  187. package/deps/simdutf/src/lasx/lasx_convert_utf32_to_utf8.cpp +589 -0
  188. package/deps/simdutf/src/lasx/lasx_convert_utf8_to_latin1.cpp +72 -0
  189. package/deps/simdutf/src/lasx/lasx_convert_utf8_to_utf16.cpp +296 -0
  190. package/deps/simdutf/src/lasx/lasx_convert_utf8_to_utf32.cpp +190 -0
  191. package/deps/simdutf/src/lasx/lasx_find.cpp +64 -0
  192. package/deps/simdutf/src/lasx/lasx_validate_utf16.cpp +13 -0
  193. package/deps/simdutf/src/lasx/lasx_validate_utf32le.cpp +84 -0
  194. package/deps/simdutf/src/lsx/implementation.cpp +1417 -0
  195. package/deps/simdutf/src/lsx/lsx_base64.cpp +675 -0
  196. package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf16.cpp +39 -0
  197. package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf32.cpp +27 -0
  198. package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf8.cpp +56 -0
  199. package/deps/simdutf/src/lsx/lsx_convert_utf16_to_latin1.cpp +64 -0
  200. package/deps/simdutf/src/lsx/lsx_convert_utf16_to_utf32.cpp +133 -0
  201. package/deps/simdutf/src/lsx/lsx_convert_utf16_to_utf8.cpp +518 -0
  202. package/deps/simdutf/src/lsx/lsx_convert_utf32_to_latin1.cpp +66 -0
  203. package/deps/simdutf/src/lsx/lsx_convert_utf32_to_utf16.cpp +155 -0
  204. package/deps/simdutf/src/lsx/lsx_convert_utf32_to_utf8.cpp +459 -0
  205. package/deps/simdutf/src/lsx/lsx_convert_utf8_to_latin1.cpp +75 -0
  206. package/deps/simdutf/src/lsx/lsx_convert_utf8_to_utf16.cpp +291 -0
  207. package/deps/simdutf/src/lsx/lsx_convert_utf8_to_utf32.cpp +179 -0
  208. package/deps/simdutf/src/lsx/lsx_find.cpp +60 -0
  209. package/deps/simdutf/src/lsx/lsx_validate_utf16.cpp +13 -0
  210. package/deps/simdutf/src/lsx/lsx_validate_utf32le.cpp +68 -0
  211. package/deps/simdutf/src/ppc64/implementation.cpp +992 -0
  212. package/deps/simdutf/src/ppc64/ppc64_base64.cpp +480 -0
  213. package/deps/simdutf/src/ppc64/ppc64_base64_internal_tests.cpp +401 -0
  214. package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf16.cpp +12 -0
  215. package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf32.cpp +12 -0
  216. package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf8.cpp +149 -0
  217. package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_latin1.cpp +67 -0
  218. package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_utf32.cpp +87 -0
  219. package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_utf8.cpp +296 -0
  220. package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_latin1.cpp +57 -0
  221. package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_utf16.cpp +117 -0
  222. package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_utf8.cpp +166 -0
  223. package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_latin1.cpp +69 -0
  224. package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_utf16.cpp +211 -0
  225. package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_utf32.cpp +153 -0
  226. package/deps/simdutf/src/ppc64/ppc64_utf16_to_utf8_tables.h +1011 -0
  227. package/deps/simdutf/src/ppc64/ppc64_utf8_length_from_latin1.cpp +37 -0
  228. package/deps/simdutf/src/ppc64/ppc64_validate_utf16.cpp +19 -0
  229. package/deps/simdutf/src/ppc64/templates.cpp +91 -0
  230. package/deps/simdutf/src/rvv/implementation.cpp +138 -0
  231. package/deps/simdutf/src/rvv/rvv_find.cpp +27 -0
  232. package/deps/simdutf/src/rvv/rvv_helpers.inl.cpp +23 -0
  233. package/deps/simdutf/src/rvv/rvv_latin1_to.inl.cpp +71 -0
  234. package/deps/simdutf/src/rvv/rvv_length_from.inl.cpp +164 -0
  235. package/deps/simdutf/src/rvv/rvv_utf16_to.inl.cpp +399 -0
  236. package/deps/simdutf/src/rvv/rvv_utf16fix.cpp +110 -0
  237. package/deps/simdutf/src/rvv/rvv_utf32_to.inl.cpp +307 -0
  238. package/deps/simdutf/src/rvv/rvv_utf8_to.inl.cpp +435 -0
  239. package/deps/simdutf/src/rvv/rvv_validate.inl.cpp +275 -0
  240. package/deps/simdutf/src/simdutf/arm64/begin.h +2 -0
  241. package/deps/simdutf/src/simdutf/arm64/bitmanipulation.h +34 -0
  242. package/deps/simdutf/src/simdutf/arm64/end.h +2 -0
  243. package/deps/simdutf/src/simdutf/arm64/implementation.h +307 -0
  244. package/deps/simdutf/src/simdutf/arm64/intrinsics.h +10 -0
  245. package/deps/simdutf/src/simdutf/arm64/simd.h +547 -0
  246. package/deps/simdutf/src/simdutf/arm64/simd16-inl.h +403 -0
  247. package/deps/simdutf/src/simdutf/arm64/simd32-inl.h +129 -0
  248. package/deps/simdutf/src/simdutf/arm64/simd64-inl.h +28 -0
  249. package/deps/simdutf/src/simdutf/arm64.h +43 -0
  250. package/deps/simdutf/src/simdutf/fallback/begin.h +1 -0
  251. package/deps/simdutf/src/simdutf/fallback/bitmanipulation.h +13 -0
  252. package/deps/simdutf/src/simdutf/fallback/end.h +1 -0
  253. package/deps/simdutf/src/simdutf/fallback/implementation.h +331 -0
  254. package/deps/simdutf/src/simdutf/fallback.h +42 -0
  255. package/deps/simdutf/src/simdutf/haswell/begin.h +15 -0
  256. package/deps/simdutf/src/simdutf/haswell/bitmanipulation.h +35 -0
  257. package/deps/simdutf/src/simdutf/haswell/end.h +13 -0
  258. package/deps/simdutf/src/simdutf/haswell/implementation.h +338 -0
  259. package/deps/simdutf/src/simdutf/haswell/intrinsics.h +67 -0
  260. package/deps/simdutf/src/simdutf/haswell/simd.h +363 -0
  261. package/deps/simdutf/src/simdutf/haswell/simd16-inl.h +261 -0
  262. package/deps/simdutf/src/simdutf/haswell/simd32-inl.h +111 -0
  263. package/deps/simdutf/src/simdutf/haswell/simd64-inl.h +34 -0
  264. package/deps/simdutf/src/simdutf/haswell.h +63 -0
  265. package/deps/simdutf/src/simdutf/icelake/begin.h +14 -0
  266. package/deps/simdutf/src/simdutf/icelake/bitmanipulation.h +44 -0
  267. package/deps/simdutf/src/simdutf/icelake/end.h +12 -0
  268. package/deps/simdutf/src/simdutf/icelake/implementation.h +346 -0
  269. package/deps/simdutf/src/simdutf/icelake/intrinsics.h +138 -0
  270. package/deps/simdutf/src/simdutf/icelake/simd.h +17 -0
  271. package/deps/simdutf/src/simdutf/icelake/simd16-inl.h +90 -0
  272. package/deps/simdutf/src/simdutf/icelake/simd32-inl.h +47 -0
  273. package/deps/simdutf/src/simdutf/icelake.h +81 -0
  274. package/deps/simdutf/src/simdutf/lasx/begin.h +8 -0
  275. package/deps/simdutf/src/simdutf/lasx/bitmanipulation.h +25 -0
  276. package/deps/simdutf/src/simdutf/lasx/end.h +8 -0
  277. package/deps/simdutf/src/simdutf/lasx/implementation.h +310 -0
  278. package/deps/simdutf/src/simdutf/lasx/intrinsics.h +319 -0
  279. package/deps/simdutf/src/simdutf/lasx/simd.h +551 -0
  280. package/deps/simdutf/src/simdutf/lasx/simd16-inl.h +234 -0
  281. package/deps/simdutf/src/simdutf/lasx/simd32-inl.h +74 -0
  282. package/deps/simdutf/src/simdutf/lasx/simd64-inl.h +52 -0
  283. package/deps/simdutf/src/simdutf/lasx.h +49 -0
  284. package/deps/simdutf/src/simdutf/lsx/begin.h +2 -0
  285. package/deps/simdutf/src/simdutf/lsx/bitmanipulation.h +25 -0
  286. package/deps/simdutf/src/simdutf/lsx/end.h +2 -0
  287. package/deps/simdutf/src/simdutf/lsx/implementation.h +309 -0
  288. package/deps/simdutf/src/simdutf/lsx/intrinsics.h +196 -0
  289. package/deps/simdutf/src/simdutf/lsx/simd.h +421 -0
  290. package/deps/simdutf/src/simdutf/lsx/simd16-inl.h +242 -0
  291. package/deps/simdutf/src/simdutf/lsx/simd32-inl.h +69 -0
  292. package/deps/simdutf/src/simdutf/lsx/simd64-inl.h +50 -0
  293. package/deps/simdutf/src/simdutf/lsx.h +52 -0
  294. package/deps/simdutf/src/simdutf/ppc64/begin.h +1 -0
  295. package/deps/simdutf/src/simdutf/ppc64/bitmanipulation.h +29 -0
  296. package/deps/simdutf/src/simdutf/ppc64/end.h +1 -0
  297. package/deps/simdutf/src/simdutf/ppc64/implementation.h +348 -0
  298. package/deps/simdutf/src/simdutf/ppc64/intrinsics.h +19 -0
  299. package/deps/simdutf/src/simdutf/ppc64/simd.h +177 -0
  300. package/deps/simdutf/src/simdutf/ppc64/simd16-inl.h +327 -0
  301. package/deps/simdutf/src/simdutf/ppc64/simd32-inl.h +247 -0
  302. package/deps/simdutf/src/simdutf/ppc64/simd8-inl.h +618 -0
  303. package/deps/simdutf/src/simdutf/ppc64.h +40 -0
  304. package/deps/simdutf/src/simdutf/rvv/begin.h +7 -0
  305. package/deps/simdutf/src/simdutf/rvv/end.h +7 -0
  306. package/deps/simdutf/src/simdutf/rvv/implementation.h +321 -0
  307. package/deps/simdutf/src/simdutf/rvv/intrinsics.h +131 -0
  308. package/deps/simdutf/src/simdutf/rvv.h +41 -0
  309. package/deps/simdutf/src/simdutf/westmere/begin.h +8 -0
  310. package/deps/simdutf/src/simdutf/westmere/bitmanipulation.h +37 -0
  311. package/deps/simdutf/src/simdutf/westmere/end.h +8 -0
  312. package/deps/simdutf/src/simdutf/westmere/implementation.h +338 -0
  313. package/deps/simdutf/src/simdutf/westmere/intrinsics.h +38 -0
  314. package/deps/simdutf/src/simdutf/westmere/simd.h +379 -0
  315. package/deps/simdutf/src/simdutf/westmere/simd16-inl.h +242 -0
  316. package/deps/simdutf/src/simdutf/westmere/simd32-inl.h +151 -0
  317. package/deps/simdutf/src/simdutf/westmere/simd64-inl.h +33 -0
  318. package/deps/simdutf/src/simdutf/westmere.h +59 -0
  319. package/deps/simdutf/src/simdutf.cpp +152 -0
  320. package/deps/simdutf/src/simdutf_c.cpp +525 -0
  321. package/deps/simdutf/src/tables/utf16_to_utf8_tables.h +768 -0
  322. package/deps/simdutf/src/tables/utf32_to_utf16_tables.h +53 -0
  323. package/deps/simdutf/src/tables/utf8_to_utf16_tables.h +826 -0
  324. package/deps/simdutf/src/westmere/implementation.cpp +1479 -0
  325. package/deps/simdutf/src/westmere/internal/loader.cpp +7 -0
  326. package/deps/simdutf/src/westmere/internal/write_v_u16_11bits_to_utf8.cpp +66 -0
  327. package/deps/simdutf/src/westmere/sse_base64.cpp +672 -0
  328. package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf16.cpp +21 -0
  329. package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf32.cpp +31 -0
  330. package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf8.cpp +71 -0
  331. package/deps/simdutf/src/westmere/sse_convert_utf16_to_latin1.cpp +70 -0
  332. package/deps/simdutf/src/westmere/sse_convert_utf16_to_utf32.cpp +206 -0
  333. package/deps/simdutf/src/westmere/sse_convert_utf16_to_utf8.cpp +504 -0
  334. package/deps/simdutf/src/westmere/sse_convert_utf32_to_latin1.cpp +82 -0
  335. package/deps/simdutf/src/westmere/sse_convert_utf32_to_utf16.cpp +209 -0
  336. package/deps/simdutf/src/westmere/sse_convert_utf32_to_utf8.cpp +589 -0
  337. package/deps/simdutf/src/westmere/sse_convert_utf8_to_latin1.cpp +58 -0
  338. package/deps/simdutf/src/westmere/sse_convert_utf8_to_utf16.cpp +197 -0
  339. package/deps/simdutf/src/westmere/sse_convert_utf8_to_utf32.cpp +141 -0
  340. package/deps/simdutf/src/westmere/sse_utf16fix.cpp +82 -0
  341. package/deps/simdutf/src/westmere/sse_validate_utf16.cpp +17 -0
  342. package/lib/commonjs/argon2.js +51 -2
  343. package/lib/commonjs/argon2.js.map +1 -1
  344. package/lib/commonjs/cipher.js +109 -11
  345. package/lib/commonjs/cipher.js.map +1 -1
  346. package/lib/commonjs/dsa.js +8 -2
  347. package/lib/commonjs/dsa.js.map +1 -1
  348. package/lib/commonjs/hash.js +15 -5
  349. package/lib/commonjs/hash.js.map +1 -1
  350. package/lib/commonjs/hkdf.js +33 -6
  351. package/lib/commonjs/hkdf.js.map +1 -1
  352. package/lib/commonjs/hmac.js +15 -5
  353. package/lib/commonjs/hmac.js.map +1 -1
  354. package/lib/commonjs/keys/publicCipher.js +10 -4
  355. package/lib/commonjs/keys/publicCipher.js.map +1 -1
  356. package/lib/commonjs/random.js +11 -2
  357. package/lib/commonjs/random.js.map +1 -1
  358. package/lib/commonjs/rsa.js +12 -5
  359. package/lib/commonjs/rsa.js.map +1 -1
  360. package/lib/commonjs/scrypt.js +47 -6
  361. package/lib/commonjs/scrypt.js.map +1 -1
  362. package/lib/commonjs/subtle.js +76 -5
  363. package/lib/commonjs/subtle.js.map +1 -1
  364. package/lib/commonjs/utils/cipher.js +18 -7
  365. package/lib/commonjs/utils/cipher.js.map +1 -1
  366. package/lib/commonjs/utils/conversion.js +33 -9
  367. package/lib/commonjs/utils/conversion.js.map +1 -1
  368. package/lib/commonjs/utils/timingSafeEqual.js +7 -2
  369. package/lib/commonjs/utils/timingSafeEqual.js.map +1 -1
  370. package/lib/commonjs/x509certificate.js +6 -6
  371. package/lib/commonjs/x509certificate.js.map +1 -1
  372. package/lib/module/argon2.js +51 -2
  373. package/lib/module/argon2.js.map +1 -1
  374. package/lib/module/cipher.js +109 -11
  375. package/lib/module/cipher.js.map +1 -1
  376. package/lib/module/dsa.js +8 -2
  377. package/lib/module/dsa.js.map +1 -1
  378. package/lib/module/hash.js +15 -5
  379. package/lib/module/hash.js.map +1 -1
  380. package/lib/module/hkdf.js +33 -6
  381. package/lib/module/hkdf.js.map +1 -1
  382. package/lib/module/hmac.js +15 -5
  383. package/lib/module/hmac.js.map +1 -1
  384. package/lib/module/keys/publicCipher.js +10 -4
  385. package/lib/module/keys/publicCipher.js.map +1 -1
  386. package/lib/module/random.js +11 -2
  387. package/lib/module/random.js.map +1 -1
  388. package/lib/module/rsa.js +11 -4
  389. package/lib/module/rsa.js.map +1 -1
  390. package/lib/module/scrypt.js +47 -6
  391. package/lib/module/scrypt.js.map +1 -1
  392. package/lib/module/subtle.js +76 -5
  393. package/lib/module/subtle.js.map +1 -1
  394. package/lib/module/utils/cipher.js +18 -7
  395. package/lib/module/utils/cipher.js.map +1 -1
  396. package/lib/module/utils/conversion.js +33 -9
  397. package/lib/module/utils/conversion.js.map +1 -1
  398. package/lib/module/utils/timingSafeEqual.js +8 -3
  399. package/lib/module/utils/timingSafeEqual.js.map +1 -1
  400. package/lib/module/x509certificate.js +6 -6
  401. package/lib/module/x509certificate.js.map +1 -1
  402. package/lib/typescript/argon2.d.ts.map +1 -1
  403. package/lib/typescript/cipher.d.ts +2 -2
  404. package/lib/typescript/cipher.d.ts.map +1 -1
  405. package/lib/typescript/dsa.d.ts.map +1 -1
  406. package/lib/typescript/hash.d.ts +2 -2
  407. package/lib/typescript/hash.d.ts.map +1 -1
  408. package/lib/typescript/hkdf.d.ts.map +1 -1
  409. package/lib/typescript/hmac.d.ts +2 -2
  410. package/lib/typescript/hmac.d.ts.map +1 -1
  411. package/lib/typescript/index.d.ts +1 -1
  412. package/lib/typescript/index.d.ts.map +1 -1
  413. package/lib/typescript/keys/publicCipher.d.ts.map +1 -1
  414. package/lib/typescript/random.d.ts.map +1 -1
  415. package/lib/typescript/rsa.d.ts.map +1 -1
  416. package/lib/typescript/scrypt.d.ts.map +1 -1
  417. package/lib/typescript/specs/utils.nitro.d.ts +0 -2
  418. package/lib/typescript/specs/utils.nitro.d.ts.map +1 -1
  419. package/lib/typescript/subtle.d.ts.map +1 -1
  420. package/lib/typescript/utils/cipher.d.ts +13 -1
  421. package/lib/typescript/utils/cipher.d.ts.map +1 -1
  422. package/lib/typescript/utils/conversion.d.ts +9 -6
  423. package/lib/typescript/utils/conversion.d.ts.map +1 -1
  424. package/lib/typescript/utils/timingSafeEqual.d.ts.map +1 -1
  425. package/lib/typescript/x509certificate.d.ts.map +1 -1
  426. package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +0 -2
  427. package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +0 -3
  428. package/package.json +38 -6
  429. package/src/argon2.ts +80 -2
  430. package/src/cipher.ts +139 -15
  431. package/src/dsa.ts +11 -2
  432. package/src/hash.ts +17 -7
  433. package/src/hkdf.ts +44 -6
  434. package/src/hmac.ts +17 -7
  435. package/src/keys/publicCipher.ts +10 -4
  436. package/src/random.ts +11 -2
  437. package/src/rsa.ts +18 -4
  438. package/src/scrypt.ts +73 -6
  439. package/src/specs/utils.nitro.ts +0 -2
  440. package/src/subtle.ts +90 -8
  441. package/src/utils/cipher.ts +30 -8
  442. package/src/utils/conversion.ts +58 -20
  443. package/src/utils/timingSafeEqual.ts +8 -3
  444. package/src/x509certificate.ts +5 -6
  445. package/deps/blake3/.cargo/config.toml +0 -2
  446. package/deps/blake3/.git-blame-ignore-revs +0 -2
  447. package/deps/blake3/.github/workflows/build_b3sum.py +0 -38
  448. package/deps/blake3/.github/workflows/ci.yml +0 -491
  449. package/deps/blake3/.github/workflows/tag.yml +0 -43
  450. package/deps/blake3/.github/workflows/upload_github_release_asset.py +0 -73
  451. package/deps/blake3/CONTRIBUTING.md +0 -31
  452. package/deps/blake3/Cargo.toml +0 -135
  453. package/deps/blake3/b3sum/Cargo.lock +0 -513
  454. package/deps/blake3/b3sum/Cargo.toml +0 -26
  455. package/deps/blake3/b3sum/README.md +0 -72
  456. package/deps/blake3/b3sum/src/main.rs +0 -564
  457. package/deps/blake3/b3sum/src/unit_tests.rs +0 -235
  458. package/deps/blake3/b3sum/tests/cli_tests.rs +0 -680
  459. package/deps/blake3/b3sum/what_does_check_do.md +0 -176
  460. package/deps/blake3/benches/bench.rs +0 -623
  461. package/deps/blake3/build.rs +0 -389
  462. package/deps/blake3/c/CMakeLists.txt +0 -383
  463. package/deps/blake3/c/CMakePresets.json +0 -73
  464. package/deps/blake3/c/Makefile.testing +0 -82
  465. package/deps/blake3/c/blake3-config.cmake.in +0 -14
  466. package/deps/blake3/c/blake3_avx2.c +0 -326
  467. package/deps/blake3/c/blake3_avx2_x86-64_unix.S +0 -1815
  468. package/deps/blake3/c/blake3_avx2_x86-64_windows_gnu.S +0 -1817
  469. package/deps/blake3/c/blake3_avx2_x86-64_windows_msvc.asm +0 -1828
  470. package/deps/blake3/c/blake3_avx512.c +0 -1388
  471. package/deps/blake3/c/blake3_avx512_x86-64_unix.S +0 -4824
  472. package/deps/blake3/c/blake3_avx512_x86-64_windows_gnu.S +0 -2615
  473. package/deps/blake3/c/blake3_avx512_x86-64_windows_msvc.asm +0 -2634
  474. package/deps/blake3/c/blake3_c_rust_bindings/Cargo.toml +0 -32
  475. package/deps/blake3/c/blake3_c_rust_bindings/README.md +0 -4
  476. package/deps/blake3/c/blake3_c_rust_bindings/benches/bench.rs +0 -477
  477. package/deps/blake3/c/blake3_c_rust_bindings/build.rs +0 -253
  478. package/deps/blake3/c/blake3_c_rust_bindings/cross_test.sh +0 -31
  479. package/deps/blake3/c/blake3_c_rust_bindings/src/lib.rs +0 -333
  480. package/deps/blake3/c/blake3_c_rust_bindings/src/test.rs +0 -696
  481. package/deps/blake3/c/blake3_sse2.c +0 -566
  482. package/deps/blake3/c/blake3_sse2_x86-64_unix.S +0 -2291
  483. package/deps/blake3/c/blake3_sse2_x86-64_windows_gnu.S +0 -2332
  484. package/deps/blake3/c/blake3_sse2_x86-64_windows_msvc.asm +0 -2350
  485. package/deps/blake3/c/blake3_sse41.c +0 -560
  486. package/deps/blake3/c/blake3_sse41_x86-64_unix.S +0 -2028
  487. package/deps/blake3/c/blake3_sse41_x86-64_windows_gnu.S +0 -2069
  488. package/deps/blake3/c/blake3_sse41_x86-64_windows_msvc.asm +0 -2089
  489. package/deps/blake3/c/blake3_tbb.cpp +0 -37
  490. package/deps/blake3/c/dependencies/CMakeLists.txt +0 -3
  491. package/deps/blake3/c/dependencies/tbb/CMakeLists.txt +0 -28
  492. package/deps/blake3/c/example.c +0 -36
  493. package/deps/blake3/c/example_tbb.c +0 -57
  494. package/deps/blake3/c/libblake3.pc.in +0 -12
  495. package/deps/blake3/c/main.c +0 -166
  496. package/deps/blake3/c/test.py +0 -97
  497. package/deps/blake3/media/B3.svg +0 -70
  498. package/deps/blake3/media/BLAKE3.svg +0 -85
  499. package/deps/blake3/media/speed.svg +0 -1474
  500. package/deps/blake3/reference_impl/Cargo.toml +0 -8
  501. package/deps/blake3/reference_impl/README.md +0 -14
  502. package/deps/blake3/reference_impl/reference_impl.rs +0 -374
  503. package/deps/blake3/src/ffi_avx2.rs +0 -65
  504. package/deps/blake3/src/ffi_avx512.rs +0 -169
  505. package/deps/blake3/src/ffi_neon.rs +0 -82
  506. package/deps/blake3/src/ffi_sse2.rs +0 -126
  507. package/deps/blake3/src/ffi_sse41.rs +0 -126
  508. package/deps/blake3/src/guts.rs +0 -60
  509. package/deps/blake3/src/hazmat.rs +0 -704
  510. package/deps/blake3/src/io.rs +0 -64
  511. package/deps/blake3/src/join.rs +0 -92
  512. package/deps/blake3/src/lib.rs +0 -1835
  513. package/deps/blake3/src/platform.rs +0 -587
  514. package/deps/blake3/src/portable.rs +0 -198
  515. package/deps/blake3/src/rust_avx2.rs +0 -474
  516. package/deps/blake3/src/rust_sse2.rs +0 -775
  517. package/deps/blake3/src/rust_sse41.rs +0 -766
  518. package/deps/blake3/src/test.rs +0 -1049
  519. package/deps/blake3/src/traits.rs +0 -227
  520. package/deps/blake3/src/wasm32_simd.rs +0 -794
  521. package/deps/blake3/test_vectors/Cargo.toml +0 -19
  522. package/deps/blake3/test_vectors/cross_test.sh +0 -25
  523. package/deps/blake3/test_vectors/src/bin/generate.rs +0 -4
  524. package/deps/blake3/test_vectors/src/lib.rs +0 -350
  525. package/deps/blake3/test_vectors/test_vectors.json +0 -217
  526. package/deps/blake3/tools/compiler_version/Cargo.toml +0 -7
  527. package/deps/blake3/tools/compiler_version/build.rs +0 -6
  528. package/deps/blake3/tools/compiler_version/src/main.rs +0 -27
  529. package/deps/blake3/tools/instruction_set_support/Cargo.toml +0 -6
  530. package/deps/blake3/tools/instruction_set_support/src/main.rs +0 -10
  531. package/deps/blake3/tools/release.md +0 -16
  532. package/deps/ncrypto/.bazelignore +0 -4
  533. package/deps/ncrypto/.bazelrc +0 -1
  534. package/deps/ncrypto/.bazelversion +0 -1
  535. package/deps/ncrypto/.clang-format +0 -111
  536. package/deps/ncrypto/.github/workflows/bazel.yml +0 -58
  537. package/deps/ncrypto/.github/workflows/commitlint.yml +0 -16
  538. package/deps/ncrypto/.github/workflows/linter.yml +0 -38
  539. package/deps/ncrypto/.github/workflows/macos.yml +0 -43
  540. package/deps/ncrypto/.github/workflows/release-please.yml +0 -16
  541. package/deps/ncrypto/.github/workflows/ubuntu.yml +0 -128
  542. package/deps/ncrypto/.github/workflows/visual-studio.yml +0 -49
  543. package/deps/ncrypto/.python-version +0 -1
  544. package/deps/ncrypto/.release-please-manifest.json +0 -3
  545. package/deps/ncrypto/BUILD.bazel +0 -44
  546. package/deps/ncrypto/CHANGELOG.md +0 -37
  547. package/deps/ncrypto/CMakeLists.txt +0 -79
  548. package/deps/ncrypto/MODULE.bazel +0 -16
  549. package/deps/ncrypto/MODULE.bazel.lock +0 -461
  550. package/deps/ncrypto/cmake/CPM.cmake +0 -1225
  551. package/deps/ncrypto/cmake/ncrypto-flags.cmake +0 -17
  552. package/deps/ncrypto/ncrypto.pc.in +0 -10
  553. package/deps/ncrypto/patches/0001-Expose-libdecrepit-so-NodeJS-can-use-it-for-ncrypto.patch +0 -28
  554. package/deps/ncrypto/pyproject.toml +0 -38
  555. package/deps/ncrypto/release-please-config.json +0 -11
  556. package/deps/ncrypto/src/CMakeLists.txt +0 -40
  557. package/deps/ncrypto/tests/BUILD.bazel +0 -11
  558. package/deps/ncrypto/tests/CMakeLists.txt +0 -7
  559. package/deps/ncrypto/tests/basic.cpp +0 -856
  560. package/deps/ncrypto/tools/run-clang-format.sh +0 -42
  561. package/lib/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,1479 @@
1
+ #include "simdutf/westmere/begin.h"
2
+
3
+ namespace simdutf {
4
+ namespace SIMDUTF_IMPLEMENTATION {
5
+ namespace {
6
+ #ifndef SIMDUTF_WESTMERE_H
7
+ #error "westmere.h must be included"
8
+ #endif
9
+ using namespace simd;
10
+
11
+ #if SIMDUTF_FEATURE_ASCII || SIMDUTF_FEATURE_DETECT_ENCODING || \
12
+ SIMDUTF_FEATURE_UTF8
13
+ simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
14
+ return input.reduce_or().is_ascii();
15
+ }
16
+ #endif // SIMDUTF_FEATURE_ASCII || SIMDUTF_FEATURE_DETECT_ENCODING ||
17
+ // SIMDUTF_FEATURE_UTF8
18
+
19
+ #if SIMDUTF_FEATURE_UTF8 || SIMDUTF_FEATURE_DETECT_ENCODING
20
+ simdutf_really_inline simd8<bool>
21
+ must_be_2_3_continuation(const simd8<uint8_t> prev2,
22
+ const simd8<uint8_t> prev3) {
23
+ simd8<uint8_t> is_third_byte =
24
+ prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be >= 0x80
25
+ simd8<uint8_t> is_fourth_byte =
26
+ prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be >= 0x80
27
+ return simd8<bool>(is_third_byte | is_fourth_byte);
28
+ }
29
+ #endif // SIMDUTF_FEATURE_UTF8 || SIMDUTF_FEATURE_DETECT_ENCODING
30
+
31
+ #if SIMDUTF_FEATURE_UTF8
32
+ #include "westmere/internal/loader.cpp"
33
+ #endif // SIMDUTF_FEATURE_UTF8
34
+
35
+ #if SIMDUTF_FEATURE_UTF16
36
+ #include "westmere/sse_utf16fix.cpp"
37
+ #endif // SIMDUTF_FEATURE_UTF16
38
+ #if SIMDUTF_FEATURE_UTF16 || SIMDUTF_FEATURE_DETECT_ENCODING
39
+ #include "westmere/sse_validate_utf16.cpp"
40
+ #endif // SIMDUTF_FEATURE_UTF16 || SIMDUTF_FEATURE_DETECT_ENCODING
41
+
42
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
43
+ #include "westmere/sse_convert_latin1_to_utf8.cpp"
44
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
45
+
46
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
47
+ #include "westmere/sse_convert_latin1_to_utf16.cpp"
48
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
49
+
50
+ #if SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
51
+ #include "westmere/sse_convert_latin1_to_utf32.cpp"
52
+ #endif // SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
53
+
54
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
55
+ #include "westmere/sse_convert_utf8_to_utf16.cpp"
56
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
57
+
58
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
59
+ #include "westmere/sse_convert_utf8_to_utf32.cpp"
60
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
61
+
62
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
63
+ #include "westmere/sse_convert_utf8_to_latin1.cpp"
64
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
65
+
66
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
67
+ #include "westmere/sse_convert_utf16_to_latin1.cpp"
68
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
69
+
70
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
71
+ #include "westmere/sse_convert_utf16_to_utf8.cpp"
72
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
73
+
74
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
75
+ #include "westmere/sse_convert_utf16_to_utf32.cpp"
76
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
77
+
78
+ #if SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
79
+ #include "westmere/sse_convert_utf32_to_latin1.cpp"
80
+ #endif // SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
81
+
82
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
83
+ #include "westmere/sse_convert_utf32_to_utf8.cpp"
84
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
85
+
86
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
87
+ #include "westmere/sse_convert_utf32_to_utf16.cpp"
88
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
89
+
90
+ #if SIMDUTF_FEATURE_BASE64
91
+ #include "westmere/sse_base64.cpp"
92
+ #endif // SIMDUTF_FEATURE_BASE64
93
+
94
+ } // unnamed namespace
95
+ } // namespace SIMDUTF_IMPLEMENTATION
96
+ } // namespace simdutf
97
+
98
+ #include "generic/buf_block_reader.h"
99
+ #if SIMDUTF_FEATURE_UTF8 || SIMDUTF_FEATURE_DETECT_ENCODING
100
+ #include "generic/utf8_validation/utf8_lookup4_algorithm.h"
101
+ #include "generic/utf8_validation/utf8_validator.h"
102
+ #endif // SIMDUTF_FEATURE_UTF8 || SIMDUTF_FEATURE_DETECT_ENCODING
103
+ #if SIMDUTF_FEATURE_ASCII
104
+ #include "generic/ascii_validation.h"
105
+ #endif // SIMDUTF_FEATURE_ASCII
106
+
107
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
108
+ // transcoding from UTF-8 to UTF-16
109
+ #include "generic/utf8_to_utf16/valid_utf8_to_utf16.h"
110
+ #include "generic/utf8_to_utf16/utf8_to_utf16.h"
111
+ #include "generic/utf8/utf16_length_from_utf8_bytemask.h"
112
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
113
+
114
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
115
+ #include "generic/utf8_to_utf32/valid_utf8_to_utf32.h"
116
+ #include "generic/utf8_to_utf32/utf8_to_utf32.h"
117
+ #include "generic/utf32.h"
118
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
119
+
120
+ #if SIMDUTF_FEATURE_UTF8
121
+ #include "generic/utf8.h"
122
+ #endif // SIMDUTF_FEATURE_UTF8
123
+ #if SIMDUTF_FEATURE_UTF16
124
+ #include "generic/utf16.h"
125
+ #include "generic/utf16/utf8_length_from_utf16_bytemask.h"
126
+ #endif // SIMDUTF_FEATURE_UTF16
127
+ #if SIMDUTF_FEATURE_UTF16 || SIMDUTF_FEATURE_DETECT_ENCODING
128
+ #include "generic/validate_utf16.h"
129
+ #endif // SIMDUTF_FEATURE_UTF16 || SIMDUTF_FEATURE_DETECT_ENCODING
130
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
131
+ #include "generic/utf8_to_latin1/utf8_to_latin1.h"
132
+ #include "generic/utf8_to_latin1/valid_utf8_to_latin1.h"
133
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
134
+
135
+ #if SIMDUTF_FEATURE_UTF32 || SIMDUTF_FEATURE_DETECT_ENCODING
136
+ #include "generic/validate_utf32.h"
137
+ #endif // SIMDUTF_FEATURE_UTF32 || SIMDUTF_FEATURE_DETECT_ENCODING
138
+
139
+ #if SIMDUTF_FEATURE_BASE64
140
+ #include "generic/base64.h"
141
+ #include "generic/find.h"
142
+ #include "generic/base64lengths.h"
143
+ #endif // SIMDUTF_FEATURE_BASE64
144
+
145
+ //
146
+ // Implementation-specific overrides
147
+ //
148
+
149
+ namespace simdutf {
150
+ namespace SIMDUTF_IMPLEMENTATION {
151
+
152
+ #if SIMDUTF_FEATURE_DETECT_ENCODING
153
+ simdutf_warn_unused int
154
+ implementation::detect_encodings(const char *input,
155
+ size_t length) const noexcept {
156
+ // If there is a BOM, then we trust it.
157
+ auto bom_encoding = simdutf::BOM::check_bom(input, length);
158
+ if (bom_encoding != encoding_type::unspecified) {
159
+ return bom_encoding;
160
+ }
161
+
162
+ int out = 0;
163
+ uint32_t utf16_err = (length % 2);
164
+ uint32_t utf32_err = (length % 4);
165
+ uint32_t ends_with_high = 0;
166
+ const auto v_d8 = simd8<uint8_t>::splat(0xd8);
167
+ const auto v_f8 = simd8<uint8_t>::splat(0xf8);
168
+ const auto v_fc = simd8<uint8_t>::splat(0xfc);
169
+ const auto v_dc = simd8<uint8_t>::splat(0xdc);
170
+ const __m128i standardmax = _mm_set1_epi32(0x10ffff);
171
+ const __m128i offset = _mm_set1_epi32(0xffff2000);
172
+ const __m128i standardoffsetmax = _mm_set1_epi32(0xfffff7ff);
173
+ __m128i currentmax = _mm_setzero_si128();
174
+ __m128i currentoffsetmax = _mm_setzero_si128();
175
+
176
+ utf8_checker c{};
177
+ buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length);
178
+ while (reader.has_full_block()) {
179
+ simd::simd8x64<uint8_t> in(reader.full_block());
180
+ // utf8 checks
181
+ c.check_next_input(in);
182
+
183
+ // utf16le checks
184
+ auto in0 = simd16<uint16_t>(in.chunks[0]);
185
+ auto in1 = simd16<uint16_t>(in.chunks[1]);
186
+ const auto t0 = in0.shr<8>();
187
+ const auto t1 = in1.shr<8>();
188
+ const auto packed1 = simd16<uint16_t>::pack(t0, t1);
189
+ auto in2 = simd16<uint16_t>(in.chunks[2]);
190
+ auto in3 = simd16<uint16_t>(in.chunks[3]);
191
+ const auto t2 = in2.shr<8>();
192
+ const auto t3 = in3.shr<8>();
193
+ const auto packed2 = simd16<uint16_t>::pack(t2, t3);
194
+
195
+ const auto surrogates_wordmask_lo = (packed1 & v_f8) == v_d8;
196
+ const auto surrogates_wordmask_hi = (packed2 & v_f8) == v_d8;
197
+ const uint32_t surrogates_bitmask =
198
+ (surrogates_wordmask_hi.to_bitmask() << 16) |
199
+ surrogates_wordmask_lo.to_bitmask();
200
+ const auto vL_lo = (packed1 & v_fc) == v_dc;
201
+ const auto vL_hi = (packed2 & v_fc) == v_dc;
202
+ const uint32_t L = (vL_hi.to_bitmask() << 16) | vL_lo.to_bitmask();
203
+ const uint32_t H = L ^ surrogates_bitmask;
204
+ utf16_err |= (((H << 1) | ends_with_high) != L);
205
+ ends_with_high = (H & 0x80000000) != 0;
206
+
207
+ // utf32le checks
208
+ currentmax = _mm_max_epu32(in.chunks[0], currentmax);
209
+ currentoffsetmax =
210
+ _mm_max_epu32(_mm_add_epi32(in.chunks[0], offset), currentoffsetmax);
211
+ currentmax = _mm_max_epu32(in.chunks[1], currentmax);
212
+ currentoffsetmax =
213
+ _mm_max_epu32(_mm_add_epi32(in.chunks[1], offset), currentoffsetmax);
214
+ currentmax = _mm_max_epu32(in.chunks[2], currentmax);
215
+ currentoffsetmax =
216
+ _mm_max_epu32(_mm_add_epi32(in.chunks[2], offset), currentoffsetmax);
217
+ currentmax = _mm_max_epu32(in.chunks[3], currentmax);
218
+ currentoffsetmax =
219
+ _mm_max_epu32(_mm_add_epi32(in.chunks[3], offset), currentoffsetmax);
220
+
221
+ reader.advance();
222
+ }
223
+
224
+ uint8_t block[64]{};
225
+ size_t idx = reader.block_index();
226
+ std::memcpy(block, &input[idx], length - idx);
227
+ simd::simd8x64<uint8_t> in(block);
228
+ c.check_next_input(in);
229
+
230
+ // utf16le last block check
231
+ auto in0 = simd16<uint16_t>(in.chunks[0]);
232
+ auto in1 = simd16<uint16_t>(in.chunks[1]);
233
+ const auto t0 = in0.shr<8>();
234
+ const auto t1 = in1.shr<8>();
235
+ const auto packed1 = simd16<uint16_t>::pack(t0, t1);
236
+ auto in2 = simd16<uint16_t>(in.chunks[2]);
237
+ auto in3 = simd16<uint16_t>(in.chunks[3]);
238
+ const auto t2 = in2.shr<8>();
239
+ const auto t3 = in3.shr<8>();
240
+ const auto packed2 = simd16<uint16_t>::pack(t2, t3);
241
+
242
+ const auto surrogates_wordmask_lo = (packed1 & v_f8) == v_d8;
243
+ const auto surrogates_wordmask_hi = (packed2 & v_f8) == v_d8;
244
+ const uint32_t surrogates_bitmask =
245
+ (surrogates_wordmask_hi.to_bitmask() << 16) |
246
+ surrogates_wordmask_lo.to_bitmask();
247
+ const auto vL_lo = (packed1 & v_fc) == v_dc;
248
+ const auto vL_hi = (packed2 & v_fc) == v_dc;
249
+ const uint32_t L = (vL_hi.to_bitmask() << 16) | vL_lo.to_bitmask();
250
+ const uint32_t H = L ^ surrogates_bitmask;
251
+ utf16_err |= (((H << 1) | ends_with_high) != L);
252
+ // this is required to check for last byte ending in high and end of input
253
+ // is reached
254
+ ends_with_high = (H & 0x80000000) != 0;
255
+ utf16_err |= ends_with_high;
256
+
257
+ // utf32le last block check
258
+ currentmax = _mm_max_epu32(in.chunks[0], currentmax);
259
+ currentoffsetmax =
260
+ _mm_max_epu32(_mm_add_epi32(in.chunks[0], offset), currentoffsetmax);
261
+ currentmax = _mm_max_epu32(in.chunks[1], currentmax);
262
+ currentoffsetmax =
263
+ _mm_max_epu32(_mm_add_epi32(in.chunks[1], offset), currentoffsetmax);
264
+ currentmax = _mm_max_epu32(in.chunks[2], currentmax);
265
+ currentoffsetmax =
266
+ _mm_max_epu32(_mm_add_epi32(in.chunks[2], offset), currentoffsetmax);
267
+ currentmax = _mm_max_epu32(in.chunks[3], currentmax);
268
+ currentoffsetmax =
269
+ _mm_max_epu32(_mm_add_epi32(in.chunks[3], offset), currentoffsetmax);
270
+
271
+ reader.advance();
272
+
273
+ c.check_eof();
274
+ bool is_valid_utf8 = !c.errors();
275
+ __m128i is_zero =
276
+ _mm_xor_si128(_mm_max_epu32(currentmax, standardmax), standardmax);
277
+ utf32_err |= (_mm_test_all_zeros(is_zero, is_zero) == 0);
278
+
279
+ is_zero = _mm_xor_si128(_mm_max_epu32(currentoffsetmax, standardoffsetmax),
280
+ standardoffsetmax);
281
+ utf32_err |= (_mm_test_all_zeros(is_zero, is_zero) == 0);
282
+ if (is_valid_utf8) {
283
+ out |= encoding_type::UTF8;
284
+ }
285
+ if (utf16_err == 0) {
286
+ out |= encoding_type::UTF16_LE;
287
+ }
288
+ if (utf32_err == 0) {
289
+ out |= encoding_type::UTF32_LE;
290
+ }
291
+ return out;
292
+ }
293
+ #endif // SIMDUTF_FEATURE_DETECT_ENCODING
294
+
295
+ #if SIMDUTF_FEATURE_UTF8 || SIMDUTF_FEATURE_DETECT_ENCODING
296
+ simdutf_warn_unused bool
297
+ implementation::validate_utf8(const char *buf, size_t len) const noexcept {
298
+ return westmere::utf8_validation::generic_validate_utf8(buf, len);
299
+ }
300
+ #endif // SIMDUTF_FEATURE_UTF8 || SIMDUTF_FEATURE_DETECT_ENCODING
301
+
302
+ #if SIMDUTF_FEATURE_UTF8
303
+ simdutf_warn_unused result implementation::validate_utf8_with_errors(
304
+ const char *buf, size_t len) const noexcept {
305
+ return westmere::utf8_validation::generic_validate_utf8_with_errors(buf, len);
306
+ }
307
+ #endif // SIMDUTF_FEATURE_UTF8
308
+
309
+ #if SIMDUTF_FEATURE_ASCII
310
+ simdutf_warn_unused bool
311
+ implementation::validate_ascii(const char *buf, size_t len) const noexcept {
312
+ return westmere::ascii_validation::generic_validate_ascii(buf, len);
313
+ }
314
+
315
+ simdutf_warn_unused result implementation::validate_ascii_with_errors(
316
+ const char *buf, size_t len) const noexcept {
317
+ return westmere::ascii_validation::generic_validate_ascii_with_errors(buf,
318
+ len);
319
+ }
320
+ #endif // SIMDUTF_FEATURE_ASCII
321
+
322
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_ASCII
323
+ simdutf_warn_unused bool
324
+ implementation::validate_utf16le_as_ascii(const char16_t *buf,
325
+ size_t len) const noexcept {
326
+ return westmere::utf16::validate_utf16_as_ascii_with_errors<
327
+ endianness::LITTLE>(buf, len)
328
+ .error == SUCCESS;
329
+ }
330
+
331
+ simdutf_warn_unused bool
332
+ implementation::validate_utf16be_as_ascii(const char16_t *buf,
333
+ size_t len) const noexcept {
334
+ return westmere::utf16::validate_utf16_as_ascii_with_errors<endianness::BIG>(
335
+ buf, len)
336
+ .error == SUCCESS;
337
+ }
338
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_ASCII
339
+
340
+ #if SIMDUTF_FEATURE_UTF16 || SIMDUTF_FEATURE_DETECT_ENCODING
341
+ simdutf_warn_unused bool
342
+ implementation::validate_utf16le(const char16_t *buf,
343
+ size_t len) const noexcept {
344
+ if (simdutf_unlikely(len == 0)) {
345
+ // empty input is valid UTF-16. protect the implementation from
346
+ // handling nullptr
347
+ return true;
348
+ }
349
+ const auto res =
350
+ westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
351
+ if (res.is_err()) {
352
+ return false;
353
+ }
354
+
355
+ if (res.count == len)
356
+ return true;
357
+
358
+ return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
359
+ len - res.count);
360
+ }
361
+ #endif // SIMDUTF_FEATURE_UTF16 || SIMDUTF_FEATURE_DETECT_ENCODING
362
+
363
+ #if SIMDUTF_FEATURE_UTF16
364
+ simdutf_warn_unused bool
365
+ implementation::validate_utf16be(const char16_t *buf,
366
+ size_t len) const noexcept {
367
+ if (simdutf_unlikely(len == 0)) {
368
+ // empty input is valid UTF-16. protect the implementation from
369
+ // handling nullptr
370
+ return true;
371
+ }
372
+ const auto res =
373
+ westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
374
+ if (res.is_err()) {
375
+ return false;
376
+ }
377
+
378
+ if (res.count == len)
379
+ return true;
380
+
381
+ return scalar::utf16::validate<endianness::BIG>(buf + res.count,
382
+ len - res.count);
383
+ }
384
+
385
+ simdutf_warn_unused result implementation::validate_utf16le_with_errors(
386
+ const char16_t *buf, size_t len) const noexcept {
387
+ const result res =
388
+ westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
389
+ if (res.count != len) {
390
+ const result scalar_res =
391
+ scalar::utf16::validate_with_errors<endianness::LITTLE>(
392
+ buf + res.count, len - res.count);
393
+ return result(scalar_res.error, res.count + scalar_res.count);
394
+ } else {
395
+ return res;
396
+ }
397
+ }
398
+
399
+ simdutf_warn_unused result implementation::validate_utf16be_with_errors(
400
+ const char16_t *buf, size_t len) const noexcept {
401
+ const result res =
402
+ westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
403
+ if (res.count != len) {
404
+ result scalar_res = scalar::utf16::validate_with_errors<endianness::BIG>(
405
+ buf + res.count, len - res.count);
406
+ return result(scalar_res.error, res.count + scalar_res.count);
407
+ } else {
408
+ return res;
409
+ }
410
+ }
411
+
412
+ void implementation::to_well_formed_utf16le(const char16_t *input, size_t len,
413
+ char16_t *output) const noexcept {
414
+ return utf16fix_sse<endianness::LITTLE>(input, len, output);
415
+ }
416
+
417
+ void implementation::to_well_formed_utf16be(const char16_t *input, size_t len,
418
+ char16_t *output) const noexcept {
419
+ return utf16fix_sse<endianness::BIG>(input, len, output);
420
+ }
421
+ #endif // SIMDUTF_FEATURE_UTF16
422
+
423
+ #if SIMDUTF_FEATURE_UTF32 || SIMDUTF_FEATURE_DETECT_ENCODING
424
+ simdutf_warn_unused bool
425
+ implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
426
+ return utf32::validate(buf, len);
427
+ }
428
+ #endif // SIMDUTF_FEATURE_UTF32 || SIMDUTF_FEATURE_DETECT_ENCODING
429
+
430
+ #if SIMDUTF_FEATURE_UTF32
431
+ simdutf_warn_unused result implementation::validate_utf32_with_errors(
432
+ const char32_t *buf, size_t len) const noexcept {
433
+ return utf32::validate_with_errors(buf, len);
434
+ }
435
+ #endif // SIMDUTF_FEATURE_UTF32
436
+
437
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
438
+ simdutf_warn_unused size_t implementation::convert_latin1_to_utf8(
439
+ const char *buf, size_t len, char *utf8_output) const noexcept {
440
+
441
+ std::pair<const char *, char *> ret =
442
+ sse_convert_latin1_to_utf8(buf, len, utf8_output);
443
+ size_t converted_chars = ret.second - utf8_output;
444
+
445
+ if (ret.first != buf + len) {
446
+ const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
447
+ ret.first, len - (ret.first - buf), ret.second);
448
+ converted_chars += scalar_converted_chars;
449
+ }
450
+
451
+ return converted_chars;
452
+ }
453
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
454
+
455
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
456
+ simdutf_warn_unused size_t implementation::convert_latin1_to_utf16le(
457
+ const char *buf, size_t len, char16_t *utf16_output) const noexcept {
458
+ std::pair<const char *, char16_t *> ret =
459
+ sse_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
460
+ if (ret.first == nullptr) {
461
+ return 0;
462
+ }
463
+ size_t converted_chars = ret.second - utf16_output;
464
+ if (ret.first != buf + len) {
465
+ const size_t scalar_converted_chars =
466
+ scalar::latin1_to_utf16::convert<endianness::LITTLE>(
467
+ ret.first, len - (ret.first - buf), ret.second);
468
+ if (scalar_converted_chars == 0) {
469
+ return 0;
470
+ }
471
+ converted_chars += scalar_converted_chars;
472
+ }
473
+ return converted_chars;
474
+ }
475
+
476
+ simdutf_warn_unused size_t implementation::convert_latin1_to_utf16be(
477
+ const char *buf, size_t len, char16_t *utf16_output) const noexcept {
478
+ std::pair<const char *, char16_t *> ret =
479
+ sse_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
480
+ if (ret.first == nullptr) {
481
+ return 0;
482
+ }
483
+ size_t converted_chars = ret.second - utf16_output;
484
+ if (ret.first != buf + len) {
485
+ const size_t scalar_converted_chars =
486
+ scalar::latin1_to_utf16::convert<endianness::BIG>(
487
+ ret.first, len - (ret.first - buf), ret.second);
488
+ if (scalar_converted_chars == 0) {
489
+ return 0;
490
+ }
491
+ converted_chars += scalar_converted_chars;
492
+ }
493
+ return converted_chars;
494
+ }
495
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
496
+
497
+ #if SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
498
+ simdutf_warn_unused size_t implementation::convert_latin1_to_utf32(
499
+ const char *buf, size_t len, char32_t *utf32_output) const noexcept {
500
+ std::pair<const char *, char32_t *> ret =
501
+ sse_convert_latin1_to_utf32(buf, len, utf32_output);
502
+ if (ret.first == nullptr) {
503
+ return 0;
504
+ }
505
+ size_t converted_chars = ret.second - utf32_output;
506
+ if (ret.first != buf + len) {
507
+ const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
508
+ ret.first, len - (ret.first - buf), ret.second);
509
+ if (scalar_converted_chars == 0) {
510
+ return 0;
511
+ }
512
+ converted_chars += scalar_converted_chars;
513
+ }
514
+ return converted_chars;
515
+ }
516
+ #endif // SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
517
+
518
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
519
+ simdutf_warn_unused size_t implementation::convert_utf8_to_latin1(
520
+ const char *buf, size_t len, char *latin1_output) const noexcept {
521
+ utf8_to_latin1::validating_transcoder converter;
522
+ return converter.convert(buf, len, latin1_output);
523
+ }
524
+
525
+ simdutf_warn_unused result implementation::convert_utf8_to_latin1_with_errors(
526
+ const char *buf, size_t len, char *latin1_output) const noexcept {
527
+ utf8_to_latin1::validating_transcoder converter;
528
+ return converter.convert_with_errors(buf, len, latin1_output);
529
+ }
530
+
531
+ simdutf_warn_unused size_t implementation::convert_valid_utf8_to_latin1(
532
+ const char *buf, size_t len, char *latin1_output) const noexcept {
533
+ return westmere::utf8_to_latin1::convert_valid(buf, len, latin1_output);
534
+ }
535
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
536
+
537
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
538
+ simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(
539
+ const char *buf, size_t len, char16_t *utf16_output) const noexcept {
540
+ utf8_to_utf16::validating_transcoder converter;
541
+ return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
542
+ }
543
+
544
+ simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(
545
+ const char *buf, size_t len, char16_t *utf16_output) const noexcept {
546
+ utf8_to_utf16::validating_transcoder converter;
547
+ return converter.convert<endianness::BIG>(buf, len, utf16_output);
548
+ }
549
+
550
+ simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(
551
+ const char *buf, size_t len, char16_t *utf16_output) const noexcept {
552
+ utf8_to_utf16::validating_transcoder converter;
553
+ return converter.convert_with_errors<endianness::LITTLE>(buf, len,
554
+ utf16_output);
555
+ }
556
+
557
+ simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(
558
+ const char *buf, size_t len, char16_t *utf16_output) const noexcept {
559
+ utf8_to_utf16::validating_transcoder converter;
560
+ return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
561
+ }
562
+
563
+ simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(
564
+ const char *input, size_t size, char16_t *utf16_output) const noexcept {
565
+ return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
566
+ utf16_output);
567
+ }
568
+
569
+ simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(
570
+ const char *input, size_t size, char16_t *utf16_output) const noexcept {
571
+ return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
572
+ utf16_output);
573
+ }
574
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
575
+
576
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
577
+ simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(
578
+ const char *buf, size_t len, char32_t *utf32_output) const noexcept {
579
+ utf8_to_utf32::validating_transcoder converter;
580
+ return converter.convert(buf, len, utf32_output);
581
+ }
582
+
583
+ simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(
584
+ const char *buf, size_t len, char32_t *utf32_output) const noexcept {
585
+ utf8_to_utf32::validating_transcoder converter;
586
+ return converter.convert_with_errors(buf, len, utf32_output);
587
+ }
588
+
589
+ simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(
590
+ const char *input, size_t size, char32_t *utf32_output) const noexcept {
591
+ return utf8_to_utf32::convert_valid(input, size, utf32_output);
592
+ }
593
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
594
+
595
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
596
+ simdutf_warn_unused size_t implementation::convert_utf16le_to_latin1(
597
+ const char16_t *buf, size_t len, char *latin1_output) const noexcept {
598
+ std::pair<const char16_t *, char *> ret =
599
+ sse_convert_utf16_to_latin1<endianness::LITTLE>(buf, len, latin1_output);
600
+ if (ret.first == nullptr) {
601
+ return 0;
602
+ }
603
+ size_t saved_bytes = ret.second - latin1_output;
604
+
605
+ if (ret.first != buf + len) {
606
+ const size_t scalar_saved_bytes =
607
+ scalar::utf16_to_latin1::convert<endianness::LITTLE>(
608
+ ret.first, len - (ret.first - buf), ret.second);
609
+ if (scalar_saved_bytes == 0) {
610
+ return 0;
611
+ }
612
+ saved_bytes += scalar_saved_bytes;
613
+ }
614
+ return saved_bytes;
615
+ }
616
+
617
+ simdutf_warn_unused size_t implementation::convert_utf16be_to_latin1(
618
+ const char16_t *buf, size_t len, char *latin1_output) const noexcept {
619
+ std::pair<const char16_t *, char *> ret =
620
+ sse_convert_utf16_to_latin1<endianness::BIG>(buf, len, latin1_output);
621
+ if (ret.first == nullptr) {
622
+ return 0;
623
+ }
624
+ size_t saved_bytes = ret.second - latin1_output;
625
+
626
+ if (ret.first != buf + len) {
627
+ const size_t scalar_saved_bytes =
628
+ scalar::utf16_to_latin1::convert<endianness::BIG>(
629
+ ret.first, len - (ret.first - buf), ret.second);
630
+ if (scalar_saved_bytes == 0) {
631
+ return 0;
632
+ }
633
+ saved_bytes += scalar_saved_bytes;
634
+ }
635
+ return saved_bytes;
636
+ }
637
+
638
+ simdutf_warn_unused result
639
+ implementation::convert_utf16le_to_latin1_with_errors(
640
+ const char16_t *buf, size_t len, char *latin1_output) const noexcept {
641
+ std::pair<result, char *> ret =
642
+ sse_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
643
+ buf, len, latin1_output);
644
+ if (ret.first.error) {
645
+ return ret.first;
646
+ } // Can return directly since scalar fallback already found correct
647
+ // ret.first.count
648
+ if (ret.first.count != len) { // All good so far, but not finished
649
+ result scalar_res =
650
+ scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
651
+ buf + ret.first.count, len - ret.first.count, ret.second);
652
+ if (scalar_res.error) {
653
+ scalar_res.count += ret.first.count;
654
+ return scalar_res;
655
+ } else {
656
+ ret.second += scalar_res.count;
657
+ }
658
+ }
659
+ ret.first.count =
660
+ ret.second -
661
+ latin1_output; // Set count to the number of 8-bit code units written
662
+ return ret.first;
663
+ }
664
+
665
+ simdutf_warn_unused result
666
+ implementation::convert_utf16be_to_latin1_with_errors(
667
+ const char16_t *buf, size_t len, char *latin1_output) const noexcept {
668
+ std::pair<result, char *> ret =
669
+ sse_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
670
+ latin1_output);
671
+ if (ret.first.error) {
672
+ return ret.first;
673
+ } // Can return directly since scalar fallback already found correct
674
+ // ret.first.count
675
+ if (ret.first.count != len) { // All good so far, but not finished
676
+ result scalar_res =
677
+ scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
678
+ buf + ret.first.count, len - ret.first.count, ret.second);
679
+ if (scalar_res.error) {
680
+ scalar_res.count += ret.first.count;
681
+ return scalar_res;
682
+ } else {
683
+ ret.second += scalar_res.count;
684
+ }
685
+ }
686
+ ret.first.count =
687
+ ret.second -
688
+ latin1_output; // Set count to the number of 8-bit code units written
689
+ return ret.first;
690
+ }
691
+
692
+ simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_latin1(
693
+ const char16_t *buf, size_t len, char *latin1_output) const noexcept {
694
+ // optimization opportunity: we could provide an optimized function.
695
+ return convert_utf16be_to_latin1(buf, len, latin1_output);
696
+ }
697
+
698
+ simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_latin1(
699
+ const char16_t *buf, size_t len, char *latin1_output) const noexcept {
700
+ // optimization opportunity: we could provide an optimized function.
701
+ return convert_utf16le_to_latin1(buf, len, latin1_output);
702
+ }
703
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_LATIN1
704
+
705
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
706
+ simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(
707
+ const char16_t *buf, size_t len, char *utf8_output) const noexcept {
708
+ std::pair<const char16_t *, char *> ret =
709
+ sse_convert_utf16_to_utf8<endianness::LITTLE>(buf, len, utf8_output);
710
+ if (ret.first == nullptr) {
711
+ return 0;
712
+ }
713
+ size_t saved_bytes = ret.second - utf8_output;
714
+ if (ret.first != buf + len) {
715
+ const size_t scalar_saved_bytes =
716
+ scalar::utf16_to_utf8::convert<endianness::LITTLE>(
717
+ ret.first, len - (ret.first - buf), ret.second);
718
+ if (scalar_saved_bytes == 0) {
719
+ return 0;
720
+ }
721
+ saved_bytes += scalar_saved_bytes;
722
+ }
723
+ return saved_bytes;
724
+ }
725
+
726
+ simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(
727
+ const char16_t *buf, size_t len, char *utf8_output) const noexcept {
728
+ std::pair<const char16_t *, char *> ret =
729
+ sse_convert_utf16_to_utf8<endianness::BIG>(buf, len, utf8_output);
730
+ if (ret.first == nullptr) {
731
+ return 0;
732
+ }
733
+ size_t saved_bytes = ret.second - utf8_output;
734
+ if (ret.first != buf + len) {
735
+ const size_t scalar_saved_bytes =
736
+ scalar::utf16_to_utf8::convert<endianness::BIG>(
737
+ ret.first, len - (ret.first - buf), ret.second);
738
+ if (scalar_saved_bytes == 0) {
739
+ return 0;
740
+ }
741
+ saved_bytes += scalar_saved_bytes;
742
+ }
743
+ return saved_bytes;
744
+ }
745
+
746
+ simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(
747
+ const char16_t *buf, size_t len, char *utf8_output) const noexcept {
748
+ // ret.first.count is always the position in the buffer, not the number of
749
+ // code units written even if finished
750
+ std::pair<result, char *> ret =
751
+ westmere::sse_convert_utf16_to_utf8_with_errors<endianness::LITTLE>(
752
+ buf, len, utf8_output);
753
+ if (ret.first.error) {
754
+ return ret.first;
755
+ } // Can return directly since scalar fallback already found correct
756
+ // ret.first.count
757
+ if (ret.first.count != len) { // All good so far, but not finished
758
+ result scalar_res =
759
+ scalar::utf16_to_utf8::convert_with_errors<endianness::LITTLE>(
760
+ buf + ret.first.count, len - ret.first.count, ret.second);
761
+ if (scalar_res.error) {
762
+ scalar_res.count += ret.first.count;
763
+ return scalar_res;
764
+ } else {
765
+ ret.second += scalar_res.count;
766
+ }
767
+ }
768
+ ret.first.count =
769
+ ret.second -
770
+ utf8_output; // Set count to the number of 8-bit code units written
771
+ return ret.first;
772
+ }
773
+
774
+ simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(
775
+ const char16_t *buf, size_t len, char *utf8_output) const noexcept {
776
+ // ret.first.count is always the position in the buffer, not the number of
777
+ // code units written even if finished
778
+ std::pair<result, char *> ret =
779
+ westmere::sse_convert_utf16_to_utf8_with_errors<endianness::BIG>(
780
+ buf, len, utf8_output);
781
+ if (ret.first.error) {
782
+ return ret.first;
783
+ } // Can return directly since scalar fallback already found correct
784
+ // ret.first.count
785
+ if (ret.first.count != len) { // All good so far, but not finished
786
+ result scalar_res =
787
+ scalar::utf16_to_utf8::convert_with_errors<endianness::BIG>(
788
+ buf + ret.first.count, len - ret.first.count, ret.second);
789
+ if (scalar_res.error) {
790
+ scalar_res.count += ret.first.count;
791
+ return scalar_res;
792
+ } else {
793
+ ret.second += scalar_res.count;
794
+ }
795
+ }
796
+ ret.first.count =
797
+ ret.second -
798
+ utf8_output; // Set count to the number of 8-bit code units written
799
+ return ret.first;
800
+ }
801
+
802
+ simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(
803
+ const char16_t *buf, size_t len, char *utf8_output) const noexcept {
804
+ return convert_utf16le_to_utf8(buf, len, utf8_output);
805
+ }
806
+
807
+ simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(
808
+ const char16_t *buf, size_t len, char *utf8_output) const noexcept {
809
+ return convert_utf16be_to_utf8(buf, len, utf8_output);
810
+ }
811
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
812
+
813
+ #if SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
814
+ simdutf_warn_unused size_t implementation::convert_utf32_to_latin1(
815
+ const char32_t *buf, size_t len, char *latin1_output) const noexcept {
816
+ std::pair<const char32_t *, char *> ret =
817
+ sse_convert_utf32_to_latin1(buf, len, latin1_output);
818
+ if (ret.first == nullptr) {
819
+ return 0;
820
+ }
821
+ size_t saved_bytes = ret.second - latin1_output;
822
+ // if (ret.first != buf + len) {
823
+ if (ret.first < buf + len) {
824
+ const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
825
+ ret.first, len - (ret.first - buf), ret.second);
826
+ if (scalar_saved_bytes == 0) {
827
+ return 0;
828
+ }
829
+ saved_bytes += scalar_saved_bytes;
830
+ }
831
+ return saved_bytes;
832
+ }
833
+
834
+ simdutf_warn_unused result implementation::convert_utf32_to_latin1_with_errors(
835
+ const char32_t *buf, size_t len, char *latin1_output) const noexcept {
836
+ // ret.first.count is always the position in the buffer, not the number of
837
+ // code units written even if finished
838
+ std::pair<result, char *> ret =
839
+ westmere::sse_convert_utf32_to_latin1_with_errors(buf, len,
840
+ latin1_output);
841
+ if (ret.first.count != len) {
842
+ result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
843
+ buf + ret.first.count, len - ret.first.count, ret.second);
844
+ if (scalar_res.error) {
845
+ scalar_res.count += ret.first.count;
846
+ return scalar_res;
847
+ } else {
848
+ ret.second += scalar_res.count;
849
+ }
850
+ }
851
+ ret.first.count =
852
+ ret.second -
853
+ latin1_output; // Set count to the number of 8-bit code units written
854
+ return ret.first;
855
+ }
856
+
857
+ simdutf_warn_unused size_t implementation::convert_valid_utf32_to_latin1(
858
+ const char32_t *buf, size_t len, char *latin1_output) const noexcept {
859
+ // optimization opportunity: we could provide an optimized function.
860
+ return convert_utf32_to_latin1(buf, len, latin1_output);
861
+ }
862
+ #endif // SIMDUTF_FEATURE_UTF32 && SIMDUTF_FEATURE_LATIN1
863
+
864
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
865
+ simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(
866
+ const char32_t *buf, size_t len, char *utf8_output) const noexcept {
867
+ std::pair<const char32_t *, char *> ret =
868
+ sse_convert_utf32_to_utf8(buf, len, utf8_output);
869
+ if (ret.first == nullptr) {
870
+ return 0;
871
+ }
872
+ size_t saved_bytes = ret.second - utf8_output;
873
+ if (ret.first != buf + len) {
874
+ const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
875
+ ret.first, len - (ret.first - buf), ret.second);
876
+ if (scalar_saved_bytes == 0) {
877
+ return 0;
878
+ }
879
+ saved_bytes += scalar_saved_bytes;
880
+ }
881
+ return saved_bytes;
882
+ }
883
+
884
+ simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(
885
+ const char32_t *buf, size_t len, char *utf8_output) const noexcept {
886
+ // ret.first.count is always the position in the buffer, not the number of
887
+ // code units written even if finished
888
+ std::pair<result, char *> ret =
889
+ westmere::sse_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
890
+ if (ret.first.count != len) {
891
+ result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
892
+ buf + ret.first.count, len - ret.first.count, ret.second);
893
+ if (scalar_res.error) {
894
+ scalar_res.count += ret.first.count;
895
+ return scalar_res;
896
+ } else {
897
+ ret.second += scalar_res.count;
898
+ }
899
+ }
900
+ ret.first.count =
901
+ ret.second -
902
+ utf8_output; // Set count to the number of 8-bit code units written
903
+ return ret.first;
904
+ }
905
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
906
+
907
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
908
+ simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(
909
+ const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
910
+ std::pair<const char16_t *, char32_t *> ret =
911
+ sse_convert_utf16_to_utf32<endianness::LITTLE>(buf, len, utf32_output);
912
+ if (ret.first == nullptr) {
913
+ return 0;
914
+ }
915
+ size_t saved_bytes = ret.second - utf32_output;
916
+ if (ret.first != buf + len) {
917
+ const size_t scalar_saved_bytes =
918
+ scalar::utf16_to_utf32::convert<endianness::LITTLE>(
919
+ ret.first, len - (ret.first - buf), ret.second);
920
+ if (scalar_saved_bytes == 0) {
921
+ return 0;
922
+ }
923
+ saved_bytes += scalar_saved_bytes;
924
+ }
925
+ return saved_bytes;
926
+ }
927
+
928
+ simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(
929
+ const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
930
+ std::pair<const char16_t *, char32_t *> ret =
931
+ sse_convert_utf16_to_utf32<endianness::BIG>(buf, len, utf32_output);
932
+ if (ret.first == nullptr) {
933
+ return 0;
934
+ }
935
+ size_t saved_bytes = ret.second - utf32_output;
936
+ if (ret.first != buf + len) {
937
+ const size_t scalar_saved_bytes =
938
+ scalar::utf16_to_utf32::convert<endianness::BIG>(
939
+ ret.first, len - (ret.first - buf), ret.second);
940
+ if (scalar_saved_bytes == 0) {
941
+ return 0;
942
+ }
943
+ saved_bytes += scalar_saved_bytes;
944
+ }
945
+ return saved_bytes;
946
+ }
947
+
948
+ simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(
949
+ const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
950
+ // ret.first.count is always the position in the buffer, not the number of
951
+ // code units written even if finished
952
+ std::pair<result, char32_t *> ret =
953
+ westmere::sse_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
954
+ buf, len, utf32_output);
955
+ if (ret.first.error) {
956
+ return ret.first;
957
+ } // Can return directly since scalar fallback already found correct
958
+ // ret.first.count
959
+ if (ret.first.count != len) { // All good so far, but not finished
960
+ result scalar_res =
961
+ scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
962
+ buf + ret.first.count, len - ret.first.count, ret.second);
963
+ if (scalar_res.error) {
964
+ scalar_res.count += ret.first.count;
965
+ return scalar_res;
966
+ } else {
967
+ ret.second += scalar_res.count;
968
+ }
969
+ }
970
+ ret.first.count =
971
+ ret.second -
972
+ utf32_output; // Set count to the number of 8-bit code units written
973
+ return ret.first;
974
+ }
975
+
976
+ simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(
977
+ const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
978
+ // ret.first.count is always the position in the buffer, not the number of
979
+ // code units written even if finished
980
+ std::pair<result, char32_t *> ret =
981
+ westmere::sse_convert_utf16_to_utf32_with_errors<endianness::BIG>(
982
+ buf, len, utf32_output);
983
+ if (ret.first.error) {
984
+ return ret.first;
985
+ } // Can return directly since scalar fallback already found correct
986
+ // ret.first.count
987
+ if (ret.first.count != len) { // All good so far, but not finished
988
+ result scalar_res =
989
+ scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
990
+ buf + ret.first.count, len - ret.first.count, ret.second);
991
+ if (scalar_res.error) {
992
+ scalar_res.count += ret.first.count;
993
+ return scalar_res;
994
+ } else {
995
+ ret.second += scalar_res.count;
996
+ }
997
+ }
998
+ ret.first.count =
999
+ ret.second -
1000
+ utf32_output; // Set count to the number of 8-bit code units written
1001
+ return ret.first;
1002
+ }
1003
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1004
+
1005
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
1006
+ simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(
1007
+ const char32_t *buf, size_t len, char *utf8_output) const noexcept {
1008
+ return convert_utf32_to_utf8(buf, len, utf8_output);
1009
+ }
1010
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
1011
+
1012
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1013
+ simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(
1014
+ const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
1015
+ std::pair<const char32_t *, char16_t *> ret =
1016
+ sse_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
1017
+ if (ret.first == nullptr) {
1018
+ return 0;
1019
+ }
1020
+ size_t saved_bytes = ret.second - utf16_output;
1021
+ if (ret.first != buf + len) {
1022
+ const size_t scalar_saved_bytes =
1023
+ scalar::utf32_to_utf16::convert<endianness::LITTLE>(
1024
+ ret.first, len - (ret.first - buf), ret.second);
1025
+ if (scalar_saved_bytes == 0) {
1026
+ return 0;
1027
+ }
1028
+ saved_bytes += scalar_saved_bytes;
1029
+ }
1030
+ return saved_bytes;
1031
+ }
1032
+
1033
+ simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(
1034
+ const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
1035
+ std::pair<const char32_t *, char16_t *> ret =
1036
+ sse_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
1037
+ if (ret.first == nullptr) {
1038
+ return 0;
1039
+ }
1040
+ size_t saved_bytes = ret.second - utf16_output;
1041
+ if (ret.first != buf + len) {
1042
+ const size_t scalar_saved_bytes =
1043
+ scalar::utf32_to_utf16::convert<endianness::BIG>(
1044
+ ret.first, len - (ret.first - buf), ret.second);
1045
+ if (scalar_saved_bytes == 0) {
1046
+ return 0;
1047
+ }
1048
+ saved_bytes += scalar_saved_bytes;
1049
+ }
1050
+ return saved_bytes;
1051
+ }
1052
+
1053
+ simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(
1054
+ const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
1055
+ // ret.first.count is always the position in the buffer, not the number of
1056
+ // code units written even if finished
1057
+ std::pair<result, char16_t *> ret =
1058
+ westmere::sse_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
1059
+ buf, len, utf16_output);
1060
+ if (ret.first.count != len) {
1061
+ result scalar_res =
1062
+ scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
1063
+ buf + ret.first.count, len - ret.first.count, ret.second);
1064
+ if (scalar_res.error) {
1065
+ scalar_res.count += ret.first.count;
1066
+ return scalar_res;
1067
+ } else {
1068
+ ret.second += scalar_res.count;
1069
+ }
1070
+ }
1071
+ ret.first.count =
1072
+ ret.second -
1073
+ utf16_output; // Set count to the number of 8-bit code units written
1074
+ return ret.first;
1075
+ }
1076
+
1077
+ simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(
1078
+ const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
1079
+ // ret.first.count is always the position in the buffer, not the number of
1080
+ // code units written even if finished
1081
+ std::pair<result, char16_t *> ret =
1082
+ westmere::sse_convert_utf32_to_utf16_with_errors<endianness::BIG>(
1083
+ buf, len, utf16_output);
1084
+ if (ret.first.count != len) {
1085
+ result scalar_res =
1086
+ scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
1087
+ buf + ret.first.count, len - ret.first.count, ret.second);
1088
+ if (scalar_res.error) {
1089
+ scalar_res.count += ret.first.count;
1090
+ return scalar_res;
1091
+ } else {
1092
+ ret.second += scalar_res.count;
1093
+ }
1094
+ }
1095
+ ret.first.count =
1096
+ ret.second -
1097
+ utf16_output; // Set count to the number of 8-bit code units written
1098
+ return ret.first;
1099
+ }
1100
+
1101
+ simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(
1102
+ const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
1103
+ return convert_utf32_to_utf16le(buf, len, utf16_output);
1104
+ }
1105
+
1106
+ simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(
1107
+ const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
1108
+ return convert_utf32_to_utf16be(buf, len, utf16_output);
1109
+ }
1110
+
1111
+ simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(
1112
+ const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
1113
+ return convert_utf16le_to_utf32(buf, len, utf32_output);
1114
+ }
1115
+
1116
+ simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(
1117
+ const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
1118
+ return convert_utf16be_to_utf32(buf, len, utf32_output);
1119
+ }
1120
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1121
+
1122
+ #if SIMDUTF_FEATURE_UTF16
1123
+ void implementation::change_endianness_utf16(const char16_t *input,
1124
+ size_t length,
1125
+ char16_t *output) const noexcept {
1126
+ utf16::change_endianness_utf16(input, length, output);
1127
+ }
1128
+
1129
+ simdutf_warn_unused size_t implementation::count_utf16le(
1130
+ const char16_t *input, size_t length) const noexcept {
1131
+ return utf16::count_code_points<endianness::LITTLE>(input, length);
1132
+ }
1133
+
1134
+ simdutf_warn_unused size_t implementation::count_utf16be(
1135
+ const char16_t *input, size_t length) const noexcept {
1136
+ return utf16::count_code_points<endianness::BIG>(input, length);
1137
+ }
1138
+ #endif // SIMDUTF_FEATURE_UTF16
1139
+
1140
+ #if SIMDUTF_FEATURE_UTF8
1141
+ simdutf_warn_unused size_t
1142
+ implementation::count_utf8(const char *input, size_t length) const noexcept {
1143
+ return utf8::count_code_points_bytemask(input, length);
1144
+ }
1145
+ #endif // SIMDUTF_FEATURE_UTF8
1146
+
1147
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
1148
+ simdutf_warn_unused size_t implementation::latin1_length_from_utf8(
1149
+ const char *buf, size_t len) const noexcept {
1150
+ return count_utf8(buf, len);
1151
+ }
1152
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
1153
+
1154
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
1155
+ simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(
1156
+ const char16_t *input, size_t length) const noexcept {
1157
+ return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
1158
+ length);
1159
+ }
1160
+
1161
+ simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(
1162
+ const char16_t *input, size_t length) const noexcept {
1163
+ return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
1164
+ }
1165
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
1166
+
1167
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
1168
+ simdutf_warn_unused size_t implementation::utf8_length_from_latin1(
1169
+ const char *input, size_t len) const noexcept {
1170
+ const uint8_t *str = reinterpret_cast<const uint8_t *>(input);
1171
+ size_t answer = len / sizeof(__m128i) * sizeof(__m128i);
1172
+ size_t i = 0;
1173
+ if (answer >= 2048) { // long strings optimization
1174
+ __m128i two_64bits = _mm_setzero_si128();
1175
+ while (i + sizeof(__m128i) <= len) {
1176
+ __m128i runner = _mm_setzero_si128();
1177
+ size_t iterations = (len - i) / sizeof(__m128i);
1178
+ if (iterations > 255) {
1179
+ iterations = 255;
1180
+ }
1181
+ size_t max_i = i + iterations * sizeof(__m128i) - sizeof(__m128i);
1182
+ for (; i + 4 * sizeof(__m128i) <= max_i; i += 4 * sizeof(__m128i)) {
1183
+ __m128i input1 = _mm_loadu_si128((const __m128i *)(str + i));
1184
+ __m128i input2 =
1185
+ _mm_loadu_si128((const __m128i *)(str + i + sizeof(__m128i)));
1186
+ __m128i input3 =
1187
+ _mm_loadu_si128((const __m128i *)(str + i + 2 * sizeof(__m128i)));
1188
+ __m128i input4 =
1189
+ _mm_loadu_si128((const __m128i *)(str + i + 3 * sizeof(__m128i)));
1190
+ __m128i input12 =
1191
+ _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input1),
1192
+ _mm_cmpgt_epi8(_mm_setzero_si128(), input2));
1193
+ __m128i input34 =
1194
+ _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input3),
1195
+ _mm_cmpgt_epi8(_mm_setzero_si128(), input4));
1196
+ __m128i input1234 = _mm_add_epi8(input12, input34);
1197
+ runner = _mm_sub_epi8(runner, input1234);
1198
+ }
1199
+ for (; i <= max_i; i += sizeof(__m128i)) {
1200
+ __m128i more_input = _mm_loadu_si128((const __m128i *)(str + i));
1201
+ runner = _mm_sub_epi8(runner,
1202
+ _mm_cmpgt_epi8(_mm_setzero_si128(), more_input));
1203
+ }
1204
+ two_64bits =
1205
+ _mm_add_epi64(two_64bits, _mm_sad_epu8(runner, _mm_setzero_si128()));
1206
+ }
1207
+ answer +=
1208
+ _mm_extract_epi64(two_64bits, 0) + _mm_extract_epi64(two_64bits, 1);
1209
+ } else if (answer > 0) { // short string optimization
1210
+ for (; i + 2 * sizeof(__m128i) <= len; i += 2 * sizeof(__m128i)) {
1211
+ __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
1212
+ uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
1213
+ answer += count_ones(non_ascii);
1214
+ latin = _mm_loadu_si128((const __m128i *)(input + i) + 1);
1215
+ non_ascii = (uint16_t)_mm_movemask_epi8(latin);
1216
+ answer += count_ones(non_ascii);
1217
+ }
1218
+ for (; i + sizeof(__m128i) <= len; i += sizeof(__m128i)) {
1219
+ __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
1220
+ uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
1221
+ answer += count_ones(non_ascii);
1222
+ }
1223
+ }
1224
+ return answer + scalar::latin1::utf8_length_from_latin1(
1225
+ reinterpret_cast<const char *>(str + i), len - i);
1226
+ }
1227
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_LATIN1
1228
+
1229
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1230
+ simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(
1231
+ const char16_t *input, size_t length) const noexcept {
1232
+ return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
1233
+ }
1234
+
1235
+ simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(
1236
+ const char16_t *input, size_t length) const noexcept {
1237
+ return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
1238
+ }
1239
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1240
+
1241
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
1242
+ simdutf_warn_unused size_t implementation::utf16_length_from_utf8(
1243
+ const char *input, size_t length) const noexcept {
1244
+ return utf8::utf16_length_from_utf8_bytemask(input, length);
1245
+ }
1246
+ simdutf_warn_unused result
1247
+ implementation::utf8_length_from_utf16le_with_replacement(
1248
+ const char16_t *input, size_t length) const noexcept {
1249
+ return utf16::utf8_length_from_utf16_with_replacement<endianness::LITTLE>(
1250
+ input, length);
1251
+ }
1252
+
1253
+ simdutf_warn_unused result
1254
+ implementation::utf8_length_from_utf16be_with_replacement(
1255
+ const char16_t *input, size_t length) const noexcept {
1256
+ return utf16::utf8_length_from_utf16_with_replacement<endianness::BIG>(
1257
+ input, length);
1258
+ }
1259
+
1260
+ simdutf_warn_unused size_t
1261
+ implementation::convert_utf16le_to_utf8_with_replacement(
1262
+ const char16_t *input, size_t length, char *utf8_buffer) const noexcept {
1263
+ return scalar::utf16_to_utf8::convert_with_replacement<endianness::LITTLE>(
1264
+ input, length, utf8_buffer);
1265
+ }
1266
+
1267
+ simdutf_warn_unused size_t
1268
+ implementation::convert_utf16be_to_utf8_with_replacement(
1269
+ const char16_t *input, size_t length, char *utf8_buffer) const noexcept {
1270
+ return scalar::utf16_to_utf8::convert_with_replacement<endianness::BIG>(
1271
+ input, length, utf8_buffer);
1272
+ }
1273
+
1274
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF16
1275
+
1276
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
1277
+ simdutf_warn_unused size_t implementation::utf8_length_from_utf32(
1278
+ const char32_t *input, size_t length) const noexcept {
1279
+ return utf32::utf8_length_from_utf32(input, length);
1280
+ }
1281
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
1282
+
1283
+ #if SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1284
+ simdutf_warn_unused size_t implementation::utf16_length_from_utf32(
1285
+ const char32_t *input, size_t length) const noexcept {
1286
+ const __m128i v_00000000 = _mm_setzero_si128();
1287
+ const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000);
1288
+ size_t pos = 0;
1289
+ size_t count = 0;
1290
+ for (; pos + 4 <= length; pos += 4) {
1291
+ __m128i in = _mm_loadu_si128((__m128i *)(input + pos));
1292
+ const __m128i surrogate_bytemask =
1293
+ _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000);
1294
+ const uint16_t surrogate_bitmask =
1295
+ static_cast<uint16_t>(_mm_movemask_epi8(surrogate_bytemask));
1296
+ size_t surrogate_count = (16 - count_ones(surrogate_bitmask)) / 4;
1297
+ count += 4 + surrogate_count;
1298
+ }
1299
+ return count +
1300
+ scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
1301
+ }
1302
+ #endif // SIMDUTF_FEATURE_UTF16 && SIMDUTF_FEATURE_UTF32
1303
+
1304
+ #if SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
1305
+ simdutf_warn_unused size_t implementation::utf32_length_from_utf8(
1306
+ const char *input, size_t length) const noexcept {
1307
+ return utf8::count_code_points(input, length);
1308
+ }
1309
+ #endif // SIMDUTF_FEATURE_UTF8 && SIMDUTF_FEATURE_UTF32
1310
+
1311
+ #if SIMDUTF_FEATURE_BASE64
1312
+ simdutf_warn_unused result implementation::base64_to_binary(
1313
+ const char *input, size_t length, char *output, base64_options options,
1314
+ last_chunk_handling_options last_chunk_options) const noexcept {
1315
+ if (options & base64_default_or_url) {
1316
+ if (options == base64_options::base64_default_or_url_accept_garbage) {
1317
+ return base64::compress_decode_base64<false, true, true>(
1318
+ output, input, length, options, last_chunk_options);
1319
+ } else {
1320
+ return base64::compress_decode_base64<false, false, true>(
1321
+ output, input, length, options, last_chunk_options);
1322
+ }
1323
+ } else if (options & base64_url) {
1324
+ if (options == base64_options::base64_url_accept_garbage) {
1325
+ return base64::compress_decode_base64<true, true, false>(
1326
+ output, input, length, options, last_chunk_options);
1327
+ } else {
1328
+ return base64::compress_decode_base64<true, false, false>(
1329
+ output, input, length, options, last_chunk_options);
1330
+ }
1331
+ } else {
1332
+ if (options == base64_options::base64_default_accept_garbage) {
1333
+ return base64::compress_decode_base64<false, true, false>(
1334
+ output, input, length, options, last_chunk_options);
1335
+ } else {
1336
+ return base64::compress_decode_base64<false, false, false>(
1337
+ output, input, length, options, last_chunk_options);
1338
+ }
1339
+ }
1340
+ }
1341
+
1342
+ simdutf_warn_unused full_result implementation::base64_to_binary_details(
1343
+ const char *input, size_t length, char *output, base64_options options,
1344
+ last_chunk_handling_options last_chunk_options) const noexcept {
1345
+ if (options & base64_default_or_url) {
1346
+ if (options == base64_options::base64_default_or_url_accept_garbage) {
1347
+ return base64::compress_decode_base64<false, true, true>(
1348
+ output, input, length, options, last_chunk_options);
1349
+ } else {
1350
+ return base64::compress_decode_base64<false, false, true>(
1351
+ output, input, length, options, last_chunk_options);
1352
+ }
1353
+ } else if (options & base64_url) {
1354
+ if (options == base64_options::base64_url_accept_garbage) {
1355
+ return base64::compress_decode_base64<true, true, false>(
1356
+ output, input, length, options, last_chunk_options);
1357
+ } else {
1358
+ return base64::compress_decode_base64<true, false, false>(
1359
+ output, input, length, options, last_chunk_options);
1360
+ }
1361
+ } else {
1362
+ if (options == base64_options::base64_default_accept_garbage) {
1363
+ return base64::compress_decode_base64<false, true, false>(
1364
+ output, input, length, options, last_chunk_options);
1365
+ } else {
1366
+ return base64::compress_decode_base64<false, false, false>(
1367
+ output, input, length, options, last_chunk_options);
1368
+ }
1369
+ }
1370
+ }
1371
+
1372
+ simdutf_warn_unused result implementation::base64_to_binary(
1373
+ const char16_t *input, size_t length, char *output, base64_options options,
1374
+ last_chunk_handling_options last_chunk_options) const noexcept {
1375
+ if (options & base64_default_or_url) {
1376
+ if (options == base64_options::base64_default_or_url_accept_garbage) {
1377
+ return base64::compress_decode_base64<false, true, true>(
1378
+ output, input, length, options, last_chunk_options);
1379
+ } else {
1380
+ return base64::compress_decode_base64<false, false, true>(
1381
+ output, input, length, options, last_chunk_options);
1382
+ }
1383
+ } else if (options & base64_url) {
1384
+ if (options == base64_options::base64_url_accept_garbage) {
1385
+ return base64::compress_decode_base64<true, true, false>(
1386
+ output, input, length, options, last_chunk_options);
1387
+ } else {
1388
+ return base64::compress_decode_base64<true, false, false>(
1389
+ output, input, length, options, last_chunk_options);
1390
+ }
1391
+ } else {
1392
+ if (options == base64_options::base64_default_accept_garbage) {
1393
+ return base64::compress_decode_base64<false, true, false>(
1394
+ output, input, length, options, last_chunk_options);
1395
+ } else {
1396
+ return base64::compress_decode_base64<false, false, false>(
1397
+ output, input, length, options, last_chunk_options);
1398
+ }
1399
+ }
1400
+ }
1401
+
1402
+ simdutf_warn_unused full_result implementation::base64_to_binary_details(
1403
+ const char16_t *input, size_t length, char *output, base64_options options,
1404
+ last_chunk_handling_options last_chunk_options) const noexcept {
1405
+ if (options & base64_default_or_url) {
1406
+ if (options == base64_options::base64_default_or_url_accept_garbage) {
1407
+ return base64::compress_decode_base64<false, true, true>(
1408
+ output, input, length, options, last_chunk_options);
1409
+ } else {
1410
+ return base64::compress_decode_base64<false, false, true>(
1411
+ output, input, length, options, last_chunk_options);
1412
+ }
1413
+ } else if (options & base64_url) {
1414
+ if (options == base64_options::base64_url_accept_garbage) {
1415
+ return base64::compress_decode_base64<true, true, false>(
1416
+ output, input, length, options, last_chunk_options);
1417
+ } else {
1418
+ return base64::compress_decode_base64<true, false, false>(
1419
+ output, input, length, options, last_chunk_options);
1420
+ }
1421
+ } else {
1422
+ if (options == base64_options::base64_default_accept_garbage) {
1423
+ return base64::compress_decode_base64<false, true, false>(
1424
+ output, input, length, options, last_chunk_options);
1425
+ } else {
1426
+ return base64::compress_decode_base64<false, false, false>(
1427
+ output, input, length, options, last_chunk_options);
1428
+ }
1429
+ }
1430
+ }
1431
+
1432
+ size_t implementation::binary_to_base64(const char *input, size_t length,
1433
+ char *output,
1434
+ base64_options options) const noexcept {
1435
+ if (options & base64_url) {
1436
+ return encode_base64<true>(output, input, length, options);
1437
+ } else {
1438
+ return encode_base64<false>(output, input, length, options);
1439
+ }
1440
+ }
1441
+
1442
+ size_t implementation::binary_to_base64_with_lines(
1443
+ const char *input, size_t length, char *output, size_t line_length,
1444
+ base64_options options) const noexcept {
1445
+ if (options & base64_url) {
1446
+ return encode_base64_impl<true, true>(output, input, length, options,
1447
+ line_length);
1448
+
1449
+ } else {
1450
+ return encode_base64_impl<false, true>(output, input, length, options,
1451
+ line_length);
1452
+ }
1453
+ }
1454
+
1455
+ const char *implementation::find(const char *start, const char *end,
1456
+ char character) const noexcept {
1457
+ return util::find(start, end, character);
1458
+ }
1459
+
1460
+ const char16_t *implementation::find(const char16_t *start, const char16_t *end,
1461
+ char16_t character) const noexcept {
1462
+ return util::find(start, end, character);
1463
+ }
1464
+
1465
+ simdutf_warn_unused size_t implementation::binary_length_from_base64(
1466
+ const char *input, size_t length) const noexcept {
1467
+ return base64_lengths::binary_length_from_base64(input, length);
1468
+ }
1469
+
1470
+ simdutf_warn_unused size_t implementation::binary_length_from_base64(
1471
+ const char16_t *input, size_t length) const noexcept {
1472
+ return base64_lengths::binary_length_from_base64(input, length);
1473
+ }
1474
+ #endif // SIMDUTF_FEATURE_BASE64
1475
+
1476
+ } // namespace SIMDUTF_IMPLEMENTATION
1477
+ } // namespace simdutf
1478
+
1479
+ #include "simdutf/westmere/end.h"