mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:37:35 +00:00
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:
parent
35040dd2c4
commit
893a9ff5b0
1 changed files with 6 additions and 1 deletions
|
@ -65,7 +65,12 @@ String Latin1Decoder::to_utf8(const StringView& input)
|
||||||
StringBuilder builder(input.length());
|
StringBuilder builder(input.length());
|
||||||
for (size_t i = 0; i < input.length(); ++i) {
|
for (size_t i = 0; i < input.length(); ++i) {
|
||||||
u8 ch = input[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();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue