Skip to content

Support locales with names ending in ".UTF-8" - fixes #28 #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/hypermail.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ char *setindex(char *dfltindex, char *indextype, char *suffix)
return (rp);
}

/*
** Convert locale name to a UTF_8 locale name.
**
** Returns an ALLOCATED string!
*/
static char *utf8locale(char *locale)
{
struct Push buff;

INIT_PUSH(buff); /* init macro */
PushString(&buff, locale);
PushString(&buff, ".UTF-8");
RETURN_PUSH(buff);
} /* end utf8locale() */


/* Print out the version number and die. */

Expand Down Expand Up @@ -365,9 +380,13 @@ int main(int argc, char **argv)
}

#ifdef HAVE_LOCALE_H
if (!setlocale(LC_ALL, locale_code)) {
if (!setlocale(LC_ALL, locale_code)) {
char *locale_code_utf8 = utf8locale(locale_code);
if (!setlocale(LC_ALL, locale_code_utf8)) {
snprintf(errmsg, sizeof(errmsg), "WARNING: locale \"%s\", not supported.\n", locale_code);
fprintf(stderr, "%s", errmsg);/* AUDIT biege: avoid format-bug warning */
}
free(locale_code_utf8);
}
#endif

Expand Down