GDB has target and host charset: https://sourceware.org/gdb/current/onlinedocs/gdb/Character-Sets.html#Character-Sets
But the code for the arguments/environment does not seem to be dependent on that in any way.
The none cycwin code uses CreateProcessA => and that cannot support anything but the local 8bit charset. (Of course that can be changed to CreateProcess(W), once args have been translated.
The file is windows-nat.c in the gdb subfolder.
I do not know if utf8 content in environment or arguments will cause any issues in other files. But I do not expect it....
Lines given as of commit
SHA-1: 1510de429446e47cb01d6030c1c172d71f9d43f6 tag gdb-10.1-release
*** line 2370
#ifdef __CYGWIN__
static void
clear_win32_environment (char **env)
{
...
for (i = 0; env[i] && *env[i]; i++)
{
...
mbstowcs (copy, env[i], len);
...
SetEnvironmentVariableW (copy, NULL);
...
#endif
========================================================
*** Line 2755
#ifdef __CYGWIN__
*** line 2763 and follow // cygallargs creaeted as utf16 copy of args
mbstowcs (cygallargs, allargs, len);
...
args = (cygwin_buf_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
* sizeof (wchar_t));
wcscpy (args, toexec);
wcscat (args, L" ");
wcscat (args, cygallargs);
*** line 2811 // convert env to utf16 / the CREATE_UNICODE_ENVIRONMENT flag is important
#ifdef CW_CVT_ENV_TO_WINENV
/* First try to create a direct Win32 copy of the POSIX environment. */
w32_env = (PWCHAR) cygwin_internal (CW_CVT_ENV_TO_WINENV, in_env);
if (w32_env != (PWCHAR) -1)
flags |= CREATE_UNICODE_ENVIRONMENT;
else
/* If that fails, fall back to old method tweaking GDB's environment. */
#endif /* CW_CVT_ENV_TO_WINENV */
{
/* Reset all Win32 environment variables to avoid leftover on next run. */
clear_win32_environment (environ);
*** line 2851 this is ret = CreateProcessW
ret = CreateProcess (0,
===============================================
*** line 2884 // the none cygwin code
#else /* !__CYGWIN__ */
*** line 2975 // the locale encoding CreateProcessA
ret = CreateProcessA (0,