163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
size_t
of_string_utf8_get_position(const char *string, size_t idx, size_t length)
{
for (size_t i = 0; i <= idx; i++)
if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
if (++idx > length)
return OF_NOT_FOUND;
return idx;
}
@implementation OFString_UTF8
- (instancetype)init
{
|
|
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
size_t
of_string_utf8_get_position(const char *string, size_t idx, size_t length)
{
for (size_t i = 0; i <= idx; i++)
if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
if (++idx > length)
@throw [OFInvalidFormatException exception];
return idx;
}
@implementation OFString_UTF8
- (instancetype)init
{
|