Merge branch '2514-charset-conundrum' into 'main'

tests: Unset CHARSET when testing locales to avoid it breaking tests

Closes #2514

See merge request GNOME/glib!2369
This commit is contained in:
Sebastian Dröge 2021-11-26 12:33:42 +00:00
commit e9eec6f1c8
2 changed files with 10 additions and 0 deletions

View File

@ -109,6 +109,12 @@ static gboolean
g_utf8_get_charset_internal (const char *raw_data,
const char **a)
{
/* Allow CHARSET to override the charset of any locale category. Users should
* probably never be setting this instead, just add the charset after a `.`
* in `LANGUAGE`/`LC_ALL`/`LC_*`/`LANG`. I cant find any reference (in
* `git log`, code comments, or man pages) to this environment variable being
* standardised or documented or even used anywhere outside GLib. Perhaps it
* should eventually be removed. */
const char *charset = g_getenv ("CHARSET");
if (charset && *charset)

View File

@ -3047,6 +3047,10 @@ main (gint argc,
* Unset it to avoid interference with tests using setlocale and translation. */
g_unsetenv ("LANGUAGE");
/* GLib uses CHARSET to allow overriding the character set used for all locale
* categories. Unset it to avoid interference with tests. */
g_unsetenv ("CHARSET");
g_test_init (&argc, &argv, NULL);
/* GDateTime Tests */