add Encoding::beginning_of_code_point()

This commit is contained in:
josh committed 2016-08-11 23:13:32 -04:00
1 parent 1aa9fb0c41
commit b2bed71ee4
2 files changed
+16

No files matched your search

+15
View File
@@ -81,3 +81,18 @@ uint8_t Encoding::num_bytes_in_code_point(Type type, const uint8_t * encoded)
}
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;
}