diff --git a/vlib/builtin/utf8.v b/vlib/builtin/utf8.v index 7128e56db6..01328f0ef1 100644 --- a/vlib/builtin/utf8.v +++ b/vlib/builtin/utf8.v @@ -191,6 +191,8 @@ pub fn utf8_str_visible_length(s string) int { pub fn string_to_ansi_not_null_terminated(_str string) []u8 { wstr := _str.to_wide() mut ansi := wide_to_ansi(wstr) - ansi.pop() // remove tailing zero + if ansi.len > 0 { + unsafe { ansi.len-- } // remove tailing zero + } return ansi } diff --git a/vlib/v/builder/msvc_windows.v b/vlib/v/builder/msvc_windows.v index 926bf5f337..1e82c8e1e8 100644 --- a/vlib/v/builder/msvc_windows.v +++ b/vlib/v/builder/msvc_windows.v @@ -355,9 +355,9 @@ pub fn (mut v Builder) cc_msvc() { a << env_ldflags } v.dump_c_options(a) - args := a.join(' ') + args := '\xEF\xBB\xBF' + a.join(' ') // write args to a file so that we dont smash createprocess - os.write_file_array(out_name_cmd_line, string_to_ansi_not_null_terminated(args)) or { + os.write_file(out_name_cmd_line, args) or { verror('Unable to write response file to "${out_name_cmd_line}"') } cmd := '"${r.full_cl_exe_path}" "@${out_name_cmd_line}"'