diff options
-rw-r--r-- | usr.bin/mandoc/term_ascii.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c index 73b6da603b0..c59159b69f0 100644 --- a/usr.bin/mandoc/term_ascii.c +++ b/usr.bin/mandoc/term_ascii.c @@ -1,7 +1,7 @@ -/* $OpenBSD: term_ascii.c,v 1.44 2017/08/23 10:50:11 schwarze Exp $ */ +/* $OpenBSD: term_ascii.c,v 1.45 2018/04/13 18:29:19 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -18,10 +18,12 @@ #include <sys/types.h> #include <assert.h> +#include <langinfo.h> #include <locale.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <wchar.h> @@ -89,7 +91,17 @@ ascii_init(enum termenc enc, const struct manoutput *outopts) v = TERMENC_LOCALE == enc ? setlocale(LC_CTYPE, "") : setlocale(LC_CTYPE, "en_US.UTF-8"); - if (NULL != v && MB_CUR_MAX > 1) { + + /* + * We only support UTF-8, + * so revert to ASCII for anything else. + */ + + if (v != NULL && + strcmp(nl_langinfo(CODESET), "UTF-8") != 0) + v = setlocale(LC_CTYPE, "C"); + + if (v != NULL && MB_CUR_MAX > 1) { p->enc = enc; p->advance = locale_advance; p->endline = locale_endline; |