Skip to content

Commit 78ff007

Browse files
committed
Add comment on UTF-16 surrogates
1 parent d3716a5 commit 78ff007

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: std/src/sys/pal/windows/api.rs

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ pub const fn utf16_len(s: &str) -> usize {
6868
n => n as usize,
6969
};
7070
i += utf8_len;
71+
// Note that UTF-16 surrogates (U+D800 to U+DFFF) are not encodable as UTF-8,
72+
// so (unlike with WTF-8) we don't have to worry about how they'll get re-encoded.
7173
len += if utf8_len < 4 { 1 } else { 2 };
7274
}
7375
len

0 commit comments

Comments
 (0)