From: Heiko Hund Date: Wed, 7 Dec 2011 17:59:21 +0000 (+0100) Subject: set Windows environment variables as UCS-2 X-Git-Tag: v2.3-alpha1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a23f8579d37186559d3e1f6cd87a27b2331d4766;p=thirdparty%2Fopenvpn.git set Windows environment variables as UCS-2 Windows uses 16 bit wide characters to represent Unicode in the process environment. Convert UTF-8 to UCS-2 and use the wide character API to set environment variables. Signed-off-by: Heiko Hund --- diff --git a/misc.c b/misc.c index 884f2b22d..1aa1be471 100644 --- a/misc.c +++ b/misc.c @@ -1082,8 +1082,8 @@ setenv_str_ex (struct env_set *es, { #if defined(WIN32) { - /*msg (M_INFO, "SetEnvironmentVariable '%s' '%s'", name_tmp, val_tmp ? val_tmp : "NULL");*/ - if (!SetEnvironmentVariable (name_tmp, val_tmp)) + if (!SetEnvironmentVariableW (wide_string (name_tmp, &gc), + wide_string (val_tmp, &gc))) msg (M_WARN | M_ERRNO, "SetEnvironmentVariable failed, name='%s', value='%s'", name_tmp, val_tmp ? val_tmp : "NULL");