mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
LibUnicode: Ensure case conversion methods increment the current index
There was one branch in these methods (the branch where a special casing was found) that neglected to update the current index.
This commit is contained in:
parent
077a693de6
commit
68b2680040
1 changed files with 8 additions and 8 deletions
|
@ -121,21 +121,21 @@ String to_unicode_lowercase_full(StringView const& string)
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (auto it = view.begin(); it != view.end(); ++it) {
|
size_t byte_length = 0;
|
||||||
|
|
||||||
|
for (auto it = view.begin(); it != view.end(); ++it, index += byte_length) {
|
||||||
u32 code_point = *it;
|
u32 code_point = *it;
|
||||||
size_t byte_length = it.underlying_code_point_length_in_bytes();
|
byte_length = it.underlying_code_point_length_in_bytes();
|
||||||
|
|
||||||
auto unicode_data = Detail::unicode_data_for_code_point(code_point);
|
auto unicode_data = Detail::unicode_data_for_code_point(code_point);
|
||||||
if (!unicode_data.has_value()) {
|
if (!unicode_data.has_value()) {
|
||||||
builder.append_code_point(code_point);
|
builder.append_code_point(code_point);
|
||||||
index += byte_length;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const* special_casing = find_matching_special_case(view, index, byte_length, *unicode_data);
|
auto const* special_casing = find_matching_special_case(view, index, byte_length, *unicode_data);
|
||||||
if (!special_casing) {
|
if (!special_casing) {
|
||||||
builder.append_code_point(unicode_data->simple_lowercase_mapping);
|
builder.append_code_point(unicode_data->simple_lowercase_mapping);
|
||||||
index += byte_length;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,21 +156,21 @@ String to_unicode_uppercase_full(StringView const& string)
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (auto it = view.begin(); it != view.end(); ++it) {
|
size_t byte_length = 0;
|
||||||
|
|
||||||
|
for (auto it = view.begin(); it != view.end(); ++it, index += byte_length) {
|
||||||
u32 code_point = *it;
|
u32 code_point = *it;
|
||||||
size_t byte_length = it.underlying_code_point_length_in_bytes();
|
byte_length = it.underlying_code_point_length_in_bytes();
|
||||||
|
|
||||||
auto unicode_data = Detail::unicode_data_for_code_point(code_point);
|
auto unicode_data = Detail::unicode_data_for_code_point(code_point);
|
||||||
if (!unicode_data.has_value()) {
|
if (!unicode_data.has_value()) {
|
||||||
builder.append_code_point(code_point);
|
builder.append_code_point(code_point);
|
||||||
index += byte_length;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const* special_casing = find_matching_special_case(view, index, byte_length, *unicode_data);
|
auto const* special_casing = find_matching_special_case(view, index, byte_length, *unicode_data);
|
||||||
if (!special_casing) {
|
if (!special_casing) {
|
||||||
builder.append_code_point(unicode_data->simple_uppercase_mapping);
|
builder.append_code_point(unicode_data->simple_uppercase_mapping);
|
||||||
index += byte_length;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue