Commit e490a0e 1 parent f8c8d3d commit e490a0e Copy full SHA for e490a0e
File tree 6 files changed +19
-1
lines changed
6 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 17
17
18
18
## Global CLI
19
19
* Fix a typo in the variable description returned by "opam var" [ #5961 @jmid ]
20
+ * Out-of-the-box UTF-8 paged --help on Windows [ #5970 @kit-ty-kate ]
20
21
21
22
## Plugins
22
23
@@ -115,6 +116,7 @@ users)
115
116
## Internal
116
117
117
118
## Internal: Windows
119
+ * Set the console to use UTF-8 on Windows using SetConsoleCP and SetConsoleOutputCP [ #5970 @kit-ty-kate ]
118
120
119
121
## Test
120
122
Original file line number Diff line number Diff line change @@ -483,9 +483,11 @@ let json_out () =
483
483
(Printexc. to_string e)
484
484
485
485
let main () =
486
- if Sys. win32 then
486
+ if Sys. win32 then begin
487
487
(* Disable the critical error handling dialog *)
488
488
ignore (OpamStubs. setErrorMode (1 lor OpamStubs. getErrorMode () ));
489
+ OpamStubs. setConsoleToUTF8 () ;
490
+ end ;
489
491
OpamStd.Sys. at_exit (fun () ->
490
492
flush_all_noerror () ;
491
493
if OpamClientConfig. (! r.print_stats) then (
Original file line number Diff line number Diff line change @@ -41,3 +41,4 @@ let win_create_process _ _ _ _ _ = that's_a_no_no
41
41
let getConsoleWindowClass = that's_a_no_no
42
42
let setErrorMode = that's_a_no_no
43
43
let getErrorMode = that's_a_no_no
44
+ let setConsoleToUTF8 = that's_a_no_no
Original file line number Diff line number Diff line change @@ -142,3 +142,6 @@ val setErrorMode : int -> int
142
142
143
143
val getErrorMode : unit -> int
144
144
(* * Windows only. Directly wraps GetErrorMode. *)
145
+
146
+ val setConsoleToUTF8 : unit -> unit
147
+ (* * Windows only. Directly wraps SetConsoleOutputCP(CP_UTF8). *)
Original file line number Diff line number Diff line change @@ -39,3 +39,4 @@ external getConsoleAlias : string -> string -> string = "OPAMW_GetConsoleAlias"
39
39
external getConsoleWindowClass : unit -> string option = " OPAMW_GetConsoleWindowClass"
40
40
external setErrorMode : int -> int = " OPAMW_SetErrorMode"
41
41
external getErrorMode : unit -> int = " OPAMW_GetErrorMode"
42
+ external setConsoleToUTF8 : unit -> unit = " OPAMW_SetConsoleToUTF8"
Original file line number Diff line number Diff line change 28
28
#include <TlHelp32.h>
29
29
#include <Knownfolders.h>
30
30
#include <Objbase.h>
31
+ #include <WinCon.h>
31
32
32
33
#include <stdio.h>
33
34
@@ -795,3 +796,11 @@ CAMLprim value OPAMW_GetErrorMode(value mode)
795
796
{
796
797
return Val_int (GetErrorMode ());
797
798
}
799
+
800
+ CAMLprim value OPAMW_SetConsoleToUTF8 (value _unit ) {
801
+ /* NOTE: Setting Input (SetConsoleCP) is necessary for more.com
802
+ * called by cmdliner to correctly output UTF-8 characters */
803
+ SetConsoleCP (CP_UTF8 );
804
+ SetConsoleOutputCP (CP_UTF8 );
805
+ return Val_unit ;
806
+ }
You can’t perform that action at this time.
0 commit comments