Windows Utf8 -> Wtf8

This commit is contained in:
Krzysztof Wolicki
2024-02-26 18:01:06 +01:00
parent edaafdf57a
commit f4e8982e5c

View File

@ -88,7 +88,7 @@ fn homeWindows(buf: []u8) !?[]u8 {
const fba = fba_instance.allocator(); const fba = fba_instance.allocator();
const drive = std.process.getEnvVarOwned(fba, "HOMEDRIVE") catch |err| switch (err) { const drive = std.process.getEnvVarOwned(fba, "HOMEDRIVE") catch |err| switch (err) {
error.OutOfMemory => return Error.BufferTooSmall, error.OutOfMemory => return Error.BufferTooSmall,
error.InvalidUtf8, error.EnvironmentVariableNotFound => return null, error.InvalidWtf8, error.EnvironmentVariableNotFound => return null,
}; };
// could shift the contents if this ever happens // could shift the contents if this ever happens
if (drive.ptr != buf.ptr) @panic("codebug"); if (drive.ptr != buf.ptr) @panic("codebug");
@ -101,7 +101,7 @@ fn homeWindows(buf: []u8) !?[]u8 {
const fba = fba_instance.allocator(); const fba = fba_instance.allocator();
const homepath = std.process.getEnvVarOwned(fba, "HOMEPATH") catch |err| switch (err) { const homepath = std.process.getEnvVarOwned(fba, "HOMEPATH") catch |err| switch (err) {
error.OutOfMemory => return Error.BufferTooSmall, error.OutOfMemory => return Error.BufferTooSmall,
error.InvalidUtf8, error.EnvironmentVariableNotFound => return null, error.InvalidWtf8, error.EnvironmentVariableNotFound => return null,
}; };
// could shift the contents if this ever happens // could shift the contents if this ever happens
if (homepath.ptr != path_buf.ptr) @panic("codebug"); if (homepath.ptr != path_buf.ptr) @panic("codebug");