--- /dev/null
+--- less-381/charset.c.orig 2004-02-29 18:44:58.924400032 +0100
++++ less-381/charset.c 2004-02-29 18:54:08.049920264 +0100
+@@ -18,13 +18,14 @@
+ #if HAVE_LOCALE
+ #include <locale.h>
+ #include <ctype.h>
++#include <langinfo.h>
+ #endif
+
+ public int utf_mode = 0;
+
+ /*
+ * Predefined character sets,
+- * selected by the LESSCHARSET environment variable.
++ * selected by the locale or the LESSCHARSET environment variable.
+ */
+ struct charset {
+ char *name;
+@@ -216,6 +217,16 @@
+ binfmt = s;
+ }
+
++static char *
++charmap2chardef(const char *s) {
++ if (strcmp(s, "UTF-8") == 0) return "utf-8";
++ if (strncmp(s, "ISO-8859-", 9) == 0) return "iso8859";
++ if (strcmp(s, "ANSI_X3.4-1968") == 0) return "ascii";
++ if (strcmp(s, "KOI8-R") == 0) return "koi8-r";
++ /* The charmap hasn't been recognized */
++ return NULL;
++}
++
+ /*
+ * Initialize charset data structures.
+ */
+@@ -242,18 +253,14 @@
+ ichardef(s);
+ return;
+ }
+-
+-#if HAVE_STRSTR
+ /*
+- * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used.
++ * Use the locale charset as a fallback.
+ */
+- if ((s = lgetenv("LC_ALL")) != NULL ||
+- (s = lgetenv("LC_CTYPE")) != NULL ||
+- (s = lgetenv("LANG")) != NULL)
+- {
+- if (strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL)
+- if (icharset("utf-8"))
+- return;
++#if HAVE_LOCALE
++ setlocale(LC_ALL, "");
++ s = charmap2chardef(nl_langinfo(CODESET));
++ if (s != NULL) {
++ if (icharset(s)) return;
+ }
+ #endif
+
+--- less-381/less.nro.orig 2004-02-29 18:57:02.153452504 +0100
++++ less-381/less.nro 2004-02-29 18:59:32.351618912 +0100
+@@ -1102,7 +1102,12 @@
+ .PP
+ A "character set" is simply a description of which characters are to
+ be considered normal, control, and binary.
+-The LESSCHARSET environment variable may be used to select a character set.
++If available, the locale settings are used to determine the character set
++used. The following locale character maps are recognized: UTF-8,
++ANSI_X3.4-1968, KOI8-R, ISO-8859-*. If the locale-based selection fails
++for you,
++the LESSCHARSET environment variable may be used to select a character
++set.
+ Possible values for LESSCHARSET are:
+ .IP ascii
+ BS, TAB, NL, CR, and formfeed are control characters,