1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

Everywhere: codepoint => code point

This commit is contained in:
Andreas Kling 2021-06-01 10:01:11 +02:00
parent a8ae8b24de
commit 12a42edd13
18 changed files with 240 additions and 240 deletions

View file

@ -71,20 +71,20 @@ Utf8View Utf8View::substring_view(size_t byte_offset, size_t byte_length) const
return Utf8View { string };
}
Utf8View Utf8View::unicode_substring_view(size_t codepoint_offset, size_t codepoint_length) const
Utf8View Utf8View::unicode_substring_view(size_t code_point_offset, size_t code_point_length) const
{
if (codepoint_length == 0)
if (code_point_length == 0)
return {};
size_t codepoint_index = 0, offset_in_bytes = 0;
size_t code_point_index = 0, offset_in_bytes = 0;
for (auto iterator = begin(); !iterator.done(); ++iterator) {
if (codepoint_index == codepoint_offset)
if (code_point_index == code_point_offset)
offset_in_bytes = byte_offset_of(iterator);
if (codepoint_index == codepoint_offset + codepoint_length - 1) {
if (code_point_index == code_point_offset + code_point_length - 1) {
size_t length_in_bytes = byte_offset_of(++iterator) - offset_in_bytes;
return substring_view(offset_in_bytes, length_in_bytes);
}
++codepoint_index;
++code_point_index;
}
VERIFY_NOT_REACHED();

View file

@ -64,8 +64,8 @@ public:
Utf8View substring_view(size_t byte_offset, size_t byte_length) const;
Utf8View substring_view(size_t byte_offset) const { return substring_view(byte_offset, byte_length() - byte_offset); }
Utf8View unicode_substring_view(size_t codepoint_offset, size_t codepoint_length) const;
Utf8View unicode_substring_view(size_t codepoint_offset) const { return unicode_substring_view(codepoint_offset, length() - codepoint_offset); }
Utf8View unicode_substring_view(size_t code_point_offset, size_t code_point_length) const;
Utf8View unicode_substring_view(size_t code_point_offset) const { return unicode_substring_view(code_point_offset, length() - code_point_offset); }
bool is_empty() const { return m_string.is_empty(); }
bool starts_with(const Utf8View&) const;