add Encoding::beginning_of_code_point()
This commit is contained in:
parent
1aa9fb0c41
commit
b2bed71ee4
@ -81,3 +81,18 @@ uint8_t Encoding::num_bytes_in_code_point(Type type, const uint8_t * encoded)
|
|||||||
}
|
}
|
||||||
return 0u;
|
return 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint8_t * Encoding::beginning_of_code_point(Type type, const uint8_t * encoded)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case UTF_8:
|
||||||
|
while ((*encoded & 0xC0u) == 0x80u)
|
||||||
|
encoded--;
|
||||||
|
return encoded;
|
||||||
|
case CP_1252:
|
||||||
|
return encoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
|
|
||||||
static Type detect_encoding(const uint8_t * buffer, size_t length);
|
static Type detect_encoding(const uint8_t * buffer, size_t length);
|
||||||
static uint8_t num_bytes_in_code_point(Type type, const uint8_t * encoded);
|
static uint8_t num_bytes_in_code_point(Type type, const uint8_t * encoded);
|
||||||
|
static const uint8_t * beginning_of_code_point(Type type, const uint8_t * encoded);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user