Mercurial > octave
annotate src/main-gui.cc @ 31629:ea0b06534a37 stable
Windows: Set console input and output codepages to UTF-8 if supported.
* src/main-cli.cc (main), src/main-gui.cc (main): Temporary set the input and
output codepage for the console to UTF-8. That is needed so that non-ASCII
characters entered at the CLI are correctly stored as UTF-8 in Octave character
arrays, and so that UTF-8 encoded character arrays are correctly displayed in
the CLI.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 03 Dec 2022 13:41:42 +0100 |
parents | 796f54d4ddbf |
children | ae0aa570c907 ec1f34091635 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30192
diff
changeset
|
3 // Copyright (C) 2012-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21608
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
30 #include <cstdlib> |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
31 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
32 #include <iostream> |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
33 #include <string> |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
34 |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
35 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE) |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
36 # include <vector> |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
37 # include <locale> |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
38 # include <codecvt> |
31629
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
39 # include <windows.h> |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
40 # include <versionhelpers.h> |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
41 #endif |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
42 |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
43 #include "liboctave-build-info.h" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
44 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
45 #include "liboctinterp-build-info.h" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
46 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
47 #include "liboctgui-build-info.h" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
48 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
49 #include "oct-env.h" |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
51 #include "octave.h" |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
52 #include "octave-build-info.h" |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
53 #include "qt-application.h" |
15884
9ede91b3872b
do system-specific initialization before installing default variable values
John W. Eaton <jwe@octave.org>
parents:
15262
diff
changeset
|
54 #include "sysdep.h" |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
56 static void |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
57 check_hg_versions (void) |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
58 { |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
59 bool ok = true; |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
60 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
61 // Each library and executable has its own definition of the hg |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
62 // id. They should always match but may be different because of a |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
63 // botched installation or incorrect LD_LIBRARY_PATH or some other |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
64 // unusual problem. |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
65 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
66 std::string octave_id = octave_hg_id (); |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
67 std::string liboctave_id = liboctave_hg_id (); |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
68 std::string liboctinterp_id = liboctinterp_hg_id (); |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
69 std::string liboctgui_id = liboctgui_hg_id (); |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
70 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
71 if (octave_id != liboctave_id) |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
72 { |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
73 std::cerr << "octave hg id (" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
74 << octave_id |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
75 << ") does not match liboctave hg id (" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
76 << liboctave_id |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
77 << ')' << std::endl; |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
78 ok = false; |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
79 } |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
80 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
81 if (octave_id != liboctinterp_id) |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
82 { |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
83 std::cerr << "octave hg id (" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
84 << octave_id |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
85 << ") does not match liboctinterp hg id (" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
86 << liboctinterp_id |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
87 << ')' << std::endl; |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
88 ok = false; |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
89 } |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
90 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
91 if (octave_id != liboctgui_id) |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
92 { |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
93 std::cerr << "octave hg id (" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
94 << octave_id |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
95 << ") does not match liboctgui hg id (" |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
96 << liboctgui_id |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
97 << ')' << std::endl; |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
98 ok = false; |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
99 } |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
100 |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
101 if (! ok) |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
102 exit (1); |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
103 } |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
104 |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
105 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE) |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
106 extern "C" |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
107 int |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
108 wmain (int argc, wchar_t **wargv) |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
109 { |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
110 static char **argv = new char * [argc + 1]; |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
111 std::vector<std::string> argv_str; |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
112 |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
113 // convert wide character strings to multibyte UTF-8 strings |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
114 std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wchar_conv; |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
115 for (int i_arg = 0; i_arg < argc; i_arg++) |
30192
8c8031be8072
Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29965
diff
changeset
|
116 argv_str.push_back (wchar_conv.to_bytes (wargv[i_arg])); |
29699
b98ae05c6b7e
avoid possible buffer corruption introduced in b6f80b1d448f
John W. Eaton <jwe@octave.org>
parents:
29540
diff
changeset
|
117 |
30192
8c8031be8072
Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29965
diff
changeset
|
118 // Get pointers to C strings not before vector is stable. |
8c8031be8072
Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29965
diff
changeset
|
119 for (int i_arg = 0; i_arg < argc; i_arg++) |
8c8031be8072
Windows: Don't get pointers to C strings while vector is still unstable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29965
diff
changeset
|
120 argv[i_arg] = &argv_str[i_arg][0]; |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
121 argv[argc] = nullptr; |
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
122 |
31629
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
123 unsigned int old_console_codepage = 0; |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
124 unsigned int old_console_output_codepage = 0; |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
125 |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
126 if (IsWindows7OrGreater ()) |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
127 { |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
128 // save old console input and output codepages |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
129 old_console_codepage = GetConsoleCP (); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
130 old_console_output_codepage = GetConsoleOutputCP (); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
131 |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
132 // set console input and output codepages to UTF-8 |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
133 SetConsoleCP (65001); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
134 SetConsoleOutputCP (65001); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
135 } |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
136 |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
137 #else |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 int |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 main (int argc, char **argv) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 { |
29540
b6f80b1d448f
Windows: Support non-ASCII characters in command line arguments.
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
141 #endif |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
142 check_hg_versions (); |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
143 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
144 octave::sys::env::set_program_name (argv[0]); |
16540
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
145 |
31629
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
146 octave::qt_application app ("octave", "octave-gui", OCTAVE_VERSION, |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
147 argc, argv); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
148 |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
149 int ret = app.execute (); |
16540
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
150 |
31629
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
151 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE) |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
152 if (IsWindows7OrGreater ()) |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
153 { |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
154 // restore previous console input and output codepages |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
155 if (old_console_codepage) |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
156 SetConsoleCP (old_console_codepage); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
157 if (old_console_output_codepage) |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
158 SetConsoleOutputCP (old_console_output_codepage); |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
159 } |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
160 #endif |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
161 |
ea0b06534a37
Windows: Set console input and output codepages to UTF-8 if supported.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
162 return ret; |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
163 } |