diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-01-11 20:37:03 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-01-13 10:47:42 +0000 |
| commit | 827bfef5508ba454992011a61ca6c6e3ed4767f3 (patch) | |
| tree | fd65676a32ab50379a207138f06c766bf1f0e41d | |
| parent | main: present invalid locale errors as a user-notification (diff) | |
main: try to force an UTF-8 locale if user’s locale isn’t UTF-8
| -rw-r--r-- | main.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -436,6 +436,25 @@ main(int argc, char *const *argv) user_notification_add_fmt(&user_notifications, USER_NOTIFICATION_ERROR, "locale '%s' is not UTF-8", locale); + + /* + * Try to force an UTF-8 locale. If we succeed, launch the + * user’s shell as usual, but add a user-notification saying + * the locale has been changed. + */ + if (setlocale(LC_CTYPE, "C.UTF-8") != NULL) { + user_notification_add( + &user_notifications, USER_NOTIFICATION_WARNING, + xstrdup("locale forcibly changed to C.UTF-8")); + bad_locale = false; + } + + else if (setlocale(LC_CTYPE, "en_US.UTF-8") != NULL) { + user_notification_add( + &user_notifications, USER_NOTIFICATION_WARNING, + xstrdup("locale forcibly changed to en_US.UTF-8")); + bad_locale = false; + } } struct config conf = {NULL}; |
