Skip to content

Commit 5773ab9

Browse files
committed
temp
1 parent c65e31e commit 5773ab9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

include/boost/json/detail/utf8.hpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,22 @@ make_u32(std::uint8_t b4, std::uint8_t b3, std::uint8_t b2, std::uint8_t b1)
4747

4848
template<endian::order = endian::order::little>
4949
constexpr
50-
std::uint32_t
51-
utf8_case5_special_number()
50+
bool
51+
utf8_case5(std::uint32_t v)
5252
{
53-
return make_u32(0x00,0x00,0x30,0xFF);
53+
return ( ( ( v & make_u32(0xC0,0xC0,0xF0,0x00) )
54+
+ make_u32(0x7F,0x7F,0x70,0x00) ) | make_u32(0x00,0x00,0x30,0x00) )
55+
== make_u32(0x00,0x00,0x30,0x00);
5456
}
5557

5658
template<>
5759
constexpr
58-
std::uint32_t
59-
utf8_case5_special_number<endian::order::big>()
60+
bool
61+
utf8_case5<endian::order::big>(std::uint32_t v)
6062
{
61-
return make_u32(0xFF,0xFF,0x30,0x00);
63+
return ( ( ( v & make_u32(0xC0,0xC0,0xF0,0x00) )
64+
+ make_u32(0x00,0x00,0x70,0xFF) ) | make_u32(0x00,0x00,0x30,0x00) )
65+
== make_u32(0x80,0x80,0x30,0x00);
6266
}
6367

6468
template<int N>
@@ -143,10 +147,7 @@ is_valid_utf8(const char* p, uint16_t first)
143147
// 4 bytes, second byte [90, BF]
144148
case 5:
145149
std::memcpy(&v, p, 4);
146-
return ( ( ( v & make_u32(0xC0,0xC0,0xF0,0x00) )
147-
+ make_u32(0x7F,0x7F,0x70,0xFF) )
148-
| make_u32(0x00,0x00,0x30,0x00) )
149-
== utf8_case5_special_number<endian::order::native>();
150+
return utf8_case5<endian::order::native>(v);
150151

151152
// 4 bytes, second byte [80, BF]
152153
case 6:

0 commit comments

Comments
 (0)