Skip to content

Commit c65e31e

Browse files
committed
temp
1 parent 2fde3b2 commit c65e31e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

include/boost/json/detail/utf8.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ make_u32(std::uint8_t b4, std::uint8_t b3, std::uint8_t b2, std::uint8_t b1)
4545
return make_u32_impl<endian::order::native>(b4, b3, b2, b1);
4646
}
4747

48+
template<endian::order = endian::order::little>
49+
constexpr
50+
std::uint32_t
51+
utf8_case5_special_number()
52+
{
53+
return make_u32(0x00,0x00,0x30,0xFF);
54+
}
55+
56+
template<>
57+
constexpr
58+
std::uint32_t
59+
utf8_case5_special_number<endian::order::big>()
60+
{
61+
return make_u32(0xFF,0xFF,0x30,0x00);
62+
}
63+
4864
template<int N>
4965
std::uint32_t
5066
load_little_endian(void const* p)
@@ -129,8 +145,8 @@ is_valid_utf8(const char* p, uint16_t first)
129145
std::memcpy(&v, p, 4);
130146
return ( ( ( v & make_u32(0xC0,0xC0,0xF0,0x00) )
131147
+ make_u32(0x7F,0x7F,0x70,0xFF) )
132-
| make_u32(0x00,0x00,0x30,0xFF) )
133-
== make_u32(0x00,0x00,0x30,0xFF);
148+
| make_u32(0x00,0x00,0x30,0x00) )
149+
== utf8_case5_special_number<endian::order::native>();
134150

135151
// 4 bytes, second byte [80, BF]
136152
case 6:

0 commit comments

Comments
 (0)