From 920ffea9b631e712ff0826911db01a76edbe7521 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 4 Feb 2012 23:05:42 +0000 Subject: On Windows, convert the USER and USERNAME environment variables from OEM codepage to UTF-8 encoding. This should fix the case where the user has a username that includes non-ASCII characters (thanks Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2495 --- src/net_client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/net_client.c') diff --git a/src/net_client.c b/src/net_client.c index e338362e..b3109ecd 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -33,6 +33,7 @@ #include "i_system.h" #include "i_timer.h" #include "m_argv.h" +#include "m_misc.h" #include "net_client.h" #include "net_common.h" #include "net_defs.h" @@ -1273,6 +1274,17 @@ void NET_CL_Init(void) net_player_name = getenv("USER"); if (net_player_name == NULL) net_player_name = getenv("USERNAME"); + + // On Windows, environment variables are in OEM codepage + // encoding, so convert to UTF8: + +#ifdef _WIN32 + if (net_player_name != NULL) + { + net_player_name = M_OEMToUTF8(net_player_name); + } +#endif + if (net_player_name == NULL) net_player_name = "Player"; } -- cgit v1.2.3