mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
AK: Replace surrogates in String::from_utf8_with_replacement_character
We are expected to replace lonely surrogates with U+FFFD when decoding UTF-8 text.
This commit is contained in:
committed by
Shannon Booth
parent
51afbf5280
commit
01ebf1eb07
Notes:
github-actions[bot]
2025-07-05 16:31:19 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/01ebf1eb07b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5313 Reviewed-by: https://github.com/shannonbooth ✅
@@ -6,7 +6,10 @@
|
||||
let decoder = new TextDecoder("utf-8");
|
||||
println(`[${decoder.decode(new Uint8Array([0x41, 0x42, 0x43]))}]`); // "ABC"
|
||||
println(`[${decoder.decode()}]`);
|
||||
} catch(e) {
|
||||
|
||||
const surrogate = decoder.decode(new Uint8Array([0xed, 0xa0, 0x80])); // U+D800
|
||||
println(`[${surrogate.codePointAt(0).toString(16)}]`);
|
||||
} catch (e) {
|
||||
println("ERROR: " + e.name + ": " + e.message);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user