summaryrefslogtreecommitdiff
path: root/deps/utf8cpp/utf8/core.h
diff options
context:
space:
mode:
authorPatrick Lewis <pat@lo5t.com>2022-04-30 22:00:40 -0700
committerGitHub <noreply@github.com>2022-05-01 07:00:40 +0200
commit94123e60f66a6d9ff5040489f6bb1c9359c2e026 (patch)
tree7a4c6be8ddf3bcf3d0e46fd09f436aa4c17d8a79 /deps/utf8cpp/utf8/core.h
parentbbd760cc1aa6be9c3675aeecdf875672959e4ce5 (diff)
chore(CI): add macos-12 (#11242)
* chore(CI): add macos-12 * Update SECURITY.md * test changing googletest git_tag to main * update utf8cpp * Update DBCStorageIterator.h Co-Authored-By: Shauren <shauren.trinity@gmail.com> Co-authored-by: Shauren <shauren.trinity@gmail.com>
Diffstat (limited to 'deps/utf8cpp/utf8/core.h')
-rw-r--r--deps/utf8cpp/utf8/core.h43
1 files changed, 26 insertions, 17 deletions
diff --git a/deps/utf8cpp/utf8/core.h b/deps/utf8cpp/utf8/core.h
index 693d388c07..de6199f2a3 100644
--- a/deps/utf8cpp/utf8/core.h
+++ b/deps/utf8cpp/utf8/core.h
@@ -30,6 +30,23 @@ DEALINGS IN THE SOFTWARE.
#include <iterator>
+// Determine the C++ standard version.
+// If the user defines UTF_CPP_CPLUSPLUS, use that.
+// Otherwise, trust the unreliable predefined macro __cplusplus
+
+#if !defined UTF_CPP_CPLUSPLUS
+ #define UTF_CPP_CPLUSPLUS __cplusplus
+#endif
+
+#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
+ #define UTF_CPP_OVERRIDE override
+ #define UTF_CPP_NOEXCEPT noexcept
+#else // C++ 98/03
+ #define UTF_CPP_OVERRIDE
+ #define UTF_CPP_NOEXCEPT throw()
+#endif // C++ 11 or later
+
+
namespace utf8
{
// The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
@@ -49,8 +66,8 @@ namespace internal
const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
- const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10);
- const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN;
+ const uint16_t LEAD_OFFSET = 0xd7c0u; // LEAD_SURROGATE_MIN - (0x10000 >> 10)
+ const uint32_t SURROGATE_OFFSET = 0xfca02400u; // 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN
// Maximum valid value for a Unicode code point
const uint32_t CODE_POINT_MAX = 0x0010ffffu;
@@ -142,7 +159,7 @@ namespace internal
if (!utf8::internal::is_trail(*it))
return INCOMPLETE_SEQUENCE;
-
+
return UTF8_OK;
}
@@ -165,7 +182,7 @@ namespace internal
{
if (it == end)
return NOT_ENOUGH_ROOM;
-
+
code_point = utf8::internal::mask8(*it);
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
@@ -222,6 +239,9 @@ namespace internal
template <typename octet_iterator>
utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point)
{
+ if (it == end)
+ return NOT_ENOUGH_ROOM;
+
// Save the original value of it so we can go back in case of failure
// Of course, it does not make much sense with i.e. stream iterators
octet_iterator original_it = it;
@@ -234,7 +254,7 @@ namespace internal
// Get trail octets and calculate the code point
utf_error err = UTF8_OK;
switch (length) {
- case 0:
+ case 0:
return INVALID_LEAD;
case 1:
err = utf8::internal::get_sequence_1(it, end, cp);
@@ -310,18 +330,7 @@ namespace internal
((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) &&
((it != end) && (utf8::internal::mask8(*it)) == bom[2])
);
- }
-
- //Deprecated in release 2.3
- template <typename octet_iterator>
- inline bool is_bom (octet_iterator it)
- {
- return (
- (utf8::internal::mask8(*it++)) == bom[0] &&
- (utf8::internal::mask8(*it++)) == bom[1] &&
- (utf8::internal::mask8(*it)) == bom[2]
- );
- }
+ }
} // namespace utf8
#endif // header guard