g_get_host_name: ensure hostname has UTF8 encoding on Windows

Ensures that the hostname returned by g_get_host_name is always UTF8 encoded.
Previously, on Windows, the returned string would be encoded in the
current codepage, if it contained non-ASCII characters.

The unit test for g_get_host_name was updated with a check to ensure
that the hostname is indeed at UTF-8 string.

https://bugzilla.gnome.org/show_bug.cgi?id=789755
This commit is contained in:
Tom Schoonjans
2017-11-01 09:52:29 +00:00
committed by Philip Withnall
parent 41112ef00d
commit d011223085
2 changed files with 15 additions and 5 deletions

View File

@@ -391,6 +391,7 @@ test_hostname (void)
name = g_get_host_name ();
g_assert (name != NULL);
g_assert_true (g_utf8_validate (name, -1, NULL));
}
#ifdef G_OS_UNIX