Skip to content

Commit

Permalink
fixup! Windows native IDN
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Sep 23, 2024
1 parent aa5b5c7 commit 692a623
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/msmtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3763,7 +3763,7 @@ void msmtp_print_conf(msmtp_cmdline_conf_t conf, account_t *account)

int main(int argc, char *argv[])
{
#if defined(W32_NATIVE) && !defined(_UNICODE) && !defined(HAVE_LIBIDN)// && !defined(ENABLE_NLS)
#if defined(W32_NATIVE) && !defined(_UNICODE) && !defined(HAVE_LIBIDN) && !defined(ENABLE_NLS)
/* We need this for proper IDN conversion later on using Windows native way
* AND proper console output.
* > At program startup, the equivalent of the following statement is executed :
Expand Down
2 changes: 2 additions & 0 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,14 @@ int net_open_socket(
/* FIXME: Something messes up locale (at least on MSYS2/UCRT64) and setlocale(LC_ALL, "") won't fix it.
* The commented code below is the way to get proper console output for hostname.
* Otherwise let's make sure we get proper IDN conversion and that is it. */
/*
char locale_name[LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR)];
GetSystemDefaultLocaleName((LPWSTR)locale_name, LOCALE_NAME_MAX_LENGTH);
size_t len = wcsnlen_s((LPWSTR)locale_name, LOCALE_NAME_MAX_LENGTH);
for (int i = 1; i <= len; ++i)
locale_name[i] = locale_name[i * 2];
setlocale(LC_ALL, locale_name);
*/
_locale_t locale = _create_locale(LC_ALL, "");
errno_t err = _mbstowcs_s_l(&conv, hostname_wide, ARRAYSIZE(hostname_wide), hostname, _TRUNCATE, locale);
_free_locale(locale);
Expand Down

0 comments on commit 692a623

Please sign in to comment.