diff options
author | Nico Weber <thakis@chromium.org> | 2020-07-22 12:42:38 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-22 19:16:00 +0200 |
commit | 01522b8d7137ca075eedfdf3857b7419b58b6785 (patch) | |
tree | 941e0f7ef3f0e73bdc076e1949c4601c68f59398 | |
parent | c9c7069f9edd6ee26fc1cf6ebfe0fc58fab35640 (diff) | |
download | serenity-01522b8d7137ca075eedfdf3857b7419b58b6785.zip |
LibTextCodec: Simplify Latin1Decoder::to_utf8
No intended behavior change.
-rw-r--r-- | Libraries/LibTextCodec/Decoder.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Libraries/LibTextCodec/Decoder.cpp b/Libraries/LibTextCodec/Decoder.cpp index 1619e58070..a00c6c6493 100644 --- a/Libraries/LibTextCodec/Decoder.cpp +++ b/Libraries/LibTextCodec/Decoder.cpp @@ -65,12 +65,8 @@ String Latin1Decoder::to_utf8(const StringView& input) StringBuilder builder(input.length()); for (size_t i = 0; i < input.length(); ++i) { u8 ch = input[i]; - if (ch & 0x80) { - builder.append(0xc0 | (ch >> 6)); - builder.append(0x80 | (ch & 0x3f)); - } else { - builder.append(ch); - } + // Latin1 is the same as the first 256 Unicode codepoints, so no mapping is needed, just utf-8 encoding. + builder.append_codepoint(ch); } return builder.to_string(); } |