about summary refs log tree commit diff
path: root/library/std/src/sys/pal/windows/api.rs
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-04-08 11:42:16 +0000
committerChris Denton <chris@chrisdenton.dev>2024-04-09 20:20:32 +0000
commit19f04a7d6878fc4c258ba3d4374e81c8bbeca2e0 (patch)
treece040cb50004824470171cbc1e2a3605ac232489 /library/std/src/sys/pal/windows/api.rs
parent952d432666e6b1a8c76c332375e3483213532670 (diff)
downloadrust-19f04a7d6878fc4c258ba3d4374e81c8bbeca2e0.tar.gz
rust-19f04a7d6878fc4c258ba3d4374e81c8bbeca2e0.zip
Add comment on UTF-16 surrogates
Diffstat (limited to 'library/std/src/sys/pal/windows/api.rs')
-rw-r--r--library/std/src/sys/pal/windows/api.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/sys/pal/windows/api.rs b/library/std/src/sys/pal/windows/api.rs
index 8613dba42d2..555ad581b85 100644
--- a/library/std/src/sys/pal/windows/api.rs
+++ b/library/std/src/sys/pal/windows/api.rs
@@ -68,6 +68,8 @@ pub const fn utf16_len(s: &str) -> usize {
             n => n as usize,
         };
         i += utf8_len;
+        // Note that UTF-16 surrogates (U+D800 to U+DFFF) are not encodable as UTF-8,
+        // so (unlike with WTF-8) we don't have to worry about how they'll get re-encoded.
         len += if utf8_len < 4 { 1 } else { 2 };
     }
     len