We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7156b61 commit c9f25bcCopy full SHA for c9f25bc
Userland/Libraries/LibTextCodec/Decoder.cpp
@@ -183,7 +183,8 @@ String UTF8Decoder::to_utf8(const StringView& input)
183
String UTF16BEDecoder::to_utf8(const StringView& input)
184
{
185
StringBuilder builder(input.length() / 2);
186
- for (size_t i = 0; i < input.length(); i += 2) {
+ size_t utf16_length = input.length() - (input.length() % 2);
187
+ for (size_t i = 0; i < utf16_length; i += 2) {
188
u16 code_point = (input[i] << 8) | input[i + 1];
189
builder.append_code_point(code_point);
190
}
0 commit comments