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