Skip to content

Commit

Permalink
Change default charset on Windows (WIN32C) from dos to utf-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Sep 24, 2023
1 parent 04746ad commit 5dcf7b5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* Add --match-shift option.

* Change default character set on Windows from dos to utf-8.

* Improve behavior of interrupt while reading non-terminated pipe
(github #414).

Expand Down
16 changes: 7 additions & 9 deletions charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,6 @@ static void set_charset(void)
{
char *s;

#if MSDOS_COMPILER==WIN32C
/*
* If the Windows console is using UTF-8, we'll use it too.
*/
if (GetConsoleOutputCP() == CP_UTF8)
if (icharset("utf-8", 1))
return;
#endif

ichardef_utf(lgetenv("LESSUTFCHARDEF"));

/*
Expand Down Expand Up @@ -476,10 +467,17 @@ static void set_charset(void)
ilocale();
#else
#if MSDOS_COMPILER
#if MSDOS_COMPILER==WIN32C
/*
* Default to "utf-8" on Windows.
*/
(void) icharset("utf-8", 1);
#else
/*
* Default to "dos".
*/
(void) icharset("dos", 1);
#endif
#else
/*
* Default to "latin1".
Expand Down
1 change: 1 addition & 0 deletions less.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ variables.
Finally, if the
.I setlocale
interface is also not available, the default character set is latin1.
On Windows the default character set is utf-8.
.PP
Control and binary characters are displayed in standout (reverse video).
Each such character is displayed in caret notation if possible
Expand Down
3 changes: 2 additions & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ v644 9/16/23 Improve ^C on non-terminated pipe; fix crash when files are
deleted; support large files and non-BMP chars on Windows;
fix # bug; don't filter header lines; fix shifting long lines;
add --match-shift.
v645 Update Unicode tables; fix ESC-} bug.
v645 Default Windows charset is utf-8; update Unicode tables;
fix ESC-} bug.
*/

char version[] = "645x";

0 comments on commit 5dcf7b5

Please sign in to comment.