LibTextCodec: Improve Latin-1 decoder so it decodes everything

I can now see Swedish letters when opening Google in the browser. :^)
This commit is contained in:
Andreas Kling 2020-05-27 19:34:27 +02:00
parent 35040dd2c4
commit 893a9ff5b0
Notes: sideshowbarker 2024-07-19 06:04:02 +09:00

View file

@ -65,7 +65,12 @@ String Latin1Decoder::to_utf8(const StringView& input)
StringBuilder builder(input.length());
for (size_t i = 0; i < input.length(); ++i) {
u8 ch = input[i];
builder.append(ch >= 0x80 ? '?' : ch);
if (ch & 0x80) {
builder.append(0xc0 | (ch >> 6));
builder.append(0x80 | (ch & 0x3f));
} else {
builder.append(ch);
}
}
return builder.to_string();
}