diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-08-10 20:44:22 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-08-10 20:44:22 +0200 |
| commit | 901bf0a2e2821caa1087b03ed308700ec9135c87 (patch) | |
| tree | e9373681322a19ca88ae245b96c98e7dd26fdce2 /lib/std | |
| parent | 73b9f657460b040eaed4145a88f76db997d73987 (diff) | |
| download | zig-901bf0a2e2821caa1087b03ed308700ec9135c87.tar.gz zig-901bf0a2e2821caa1087b03ed308700ec9135c87.zip | |
Convert prefix from u8 to u16 programmatically
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/os/windows.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index cf42266d26..c93feb20d7 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -1002,7 +1002,10 @@ pub fn GetFinalPathNameByHandle( // Look for `\DosDevices\` prefix. We don't really care if there are more than one symlinks // with traditional DOS drive letters, so pick the first one available. - const prefix = &[_]u16{ '\\', 'D', 'o', 's', 'D', 'e', 'v', 'i', 'c', 'e', 's', '\\' }; + const prefix_u8 = "\\DosDevices\\"; + var prefix_buf_u16: [prefix_u8.len]u16 = undefined; + const prefix_len_u16 = std.unicode.utf8ToUtf16Le(prefix_buf_u16[0..], prefix_u8[0..]) catch unreachable; + const prefix = prefix_buf_u16[0..prefix_len_u16]; if (std.mem.startsWith(u16, symlink, prefix)) { const drive_letter = symlink[prefix.len..]; |
