@@ -49,14 +49,9 @@ static FORCE_INLINE_ATTR bool utf8_range_AsciiIsAscii(unsigned char c)
49
49
return c < 128 ;
50
50
}
51
51
52
- static FORCE_INLINE_ATTR bool utf8_range_IsTrailByteOk (const char c)
52
+ static FORCE_INLINE_ATTR bool utf8_range_IsTrailByteOk (unsigned char c)
53
53
{
54
- return static_cast <int8_t >(c) <= static_cast <int8_t >(0xBF );
55
- }
56
-
57
- static FORCE_INLINE_ATTR bool utf8_range_IsTrailByteOk (const unsigned char c)
58
- {
59
- return utf8_range_IsTrailByteOk (static_cast <const char >(c));
54
+ return c <= static_cast <unsigned char >(0xBF );
60
55
}
61
56
62
57
/* If return_position is false then it returns 1 if |data| is a valid utf8
@@ -98,7 +93,8 @@ static size_t utf8_range_ValidateUTF8Naive(const char *data, const char *end, in
98
93
continue ;
99
94
}
100
95
/* [C2..DF], [80..BF] -> 2 bytes */
101
- if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF && utf8_range_IsTrailByteOk (data[1 ]))
96
+ if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF &&
97
+ utf8_range_IsTrailByteOk (static_cast <unsigned char >(data[1 ])))
102
98
{
103
99
codepoint_bytes = 2 ;
104
100
continue ;
@@ -168,15 +164,15 @@ static size_t utf8_range_ValidateUTF8Naive(const char *data, const char *end, in
168
164
static inline int utf8_range_CodepointSkipBackwards (int32_t codepoint_word)
169
165
{
170
166
const int8_t *const codepoint = (const int8_t *)(&codepoint_word);
171
- if (!utf8_range_IsTrailByteOk (codepoint[3 ]))
167
+ if (!utf8_range_IsTrailByteOk (static_cast < unsigned char >( codepoint[3 ]) ))
172
168
{
173
169
return 1 ;
174
170
}
175
- else if (!utf8_range_IsTrailByteOk (codepoint[2 ]))
171
+ else if (!utf8_range_IsTrailByteOk (static_cast < unsigned char >( codepoint[2 ]) ))
176
172
{
177
173
return 2 ;
178
174
}
179
- else if (!utf8_range_IsTrailByteOk (codepoint[1 ]))
175
+ else if (!utf8_range_IsTrailByteOk (static_cast < unsigned char >( codepoint[1 ]) ))
180
176
{
181
177
return 3 ;
182
178
}
0 commit comments