From 68b87918df9ad82cf3161f323c55f2e238319922 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Tue, 13 Feb 2024 16:56:50 -0800 Subject: Fix handling of Windows (WTF-16) and WASI (UTF-8) paths Windows paths now use WTF-16 <-> WTF-8 conversion everywhere, which is lossless. Previously, conversion of ill-formed UTF-16 paths would either fail or invoke illegal behavior. WASI paths must be valid UTF-8, and the relevant function calls have been updated to handle the possibility of failure due to paths not being encoded/encodable as valid UTF-8. Closes #18694 Closes #1774 Closes #2565 --- lib/std/fs/File.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/std/fs/File.zig') diff --git a/lib/std/fs/File.zig b/lib/std/fs/File.zig index 20b3976ea6..669f1b72e3 100644 --- a/lib/std/fs/File.zig +++ b/lib/std/fs/File.zig @@ -40,8 +40,11 @@ pub const OpenError = error{ AccessDenied, PipeBusy, NameTooLong, - /// On Windows, file paths must be valid Unicode. + /// WASI-only; file paths must be valid UTF-8. InvalidUtf8, + /// Windows-only; file paths provided by the user must be valid WTF-8. + /// https://simonsapin.github.io/wtf-8/ + InvalidWtf8, /// On Windows, file paths cannot contain these characters: /// '/', '*', '?', '"', '<', '>', '|' BadPathName, -- cgit v1.2.3