From d0e2083fdd1737203f8b732d4cc192884caa7379 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Fri, 9 Feb 2001 22:43:39 +0000 Subject: Implement CODESET --- lib/libc/locale/nl_langinfo.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/libc/locale/nl_langinfo.c b/lib/libc/locale/nl_langinfo.c index 50dcd2037675..f94736d4d5f3 100644 --- a/lib/libc/locale/nl_langinfo.c +++ b/lib/libc/locale/nl_langinfo.c @@ -26,7 +26,9 @@ * $FreeBSD$ */ -#include "langinfo.h" +#include +#include +#include #include "../stdtime/timelocal.h" #include "lnumeric.h" #include "lmonetary.h" @@ -37,11 +39,18 @@ char * nl_langinfo(nl_item item) { - char *ret; + char *ret, *s, *cs; switch (item) { case CODESET: - ret = ""; /* XXX: need to be implemented */ + ret = ""; + if ((s = setlocale(LC_CTYPE, NULL)) != NULL) { + if ((cs = strchr(s, '.')) != NULL) + ret = cs + 1; + else if (strcmp(s, "C") == 0 || + strcmp(s, "POSIX") == 0) + ret = "US-ASCII"; + } break; case D_T_FMT: ret = (char *) __get_current_time_locale()->c_fmt; -- cgit v1.3