Windows UTF-8 input/output
PATCH 1/1 Windows UTF-8 input/output
This patch makes openvpn read unicode from the console and convert the input to UTF-8. And then display UTF-8 output to the console correctly.
--- configure.ac | 1 + openvpn.c | 4 ++++ win32.c | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletions(-)
configure.ac +1 -0
@@ -343,6 +343,7 @@ case "$host" in OPENVPN_ADD_LIBS(-lcrypt32) OPENVPN_ADD_LIBS(-liphlpapi) OPENVPN_ADD_LIBS(-lwinmm) + OPENVPN_ADD_LIBS(-lshell32) ;; *-*-dragonfly*) AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFlyBSD?])
openvpn.c +4 -0
@@ -131,6 +131,10 @@ main (int argc, char *argv[])return 1 ;#endif +#ifdef TARGET_WIN32 +SetConsoleOutputCP (CP_UTF8 ); +#endif +CLEAR (c);/* signify first time for components which can
win32.c +7 -1
@@ -763,6 +763,7 @@ get_console_input_win32 (const char *prompt, const bool echo, char *input, constbool is_console = (GetFileType (in) ==FILE_TYPE_CHAR );DWORD flags_save =0 ;int status =0 ; +WCHAR *winput;if (is_console) {
@@ -777,10 +778,15 @@ get_console_input_win32 (const char *prompt, const bool echo, char *input, const is_console =0 ; } - status =ReadFile (in, input, capacity, &len,NULL ); + winput =malloc (capacity *sizeof (WCHAR )); +if (winput ==NULL ) +return false; + status =ReadConsoleW (in, winput, capacity, &len,NULL ); +WideCharToMultiByte (CP_UTF8 ,0 , winput, len, input, capacity,NULL ,NULL );string_null_terminate (input, (int )len, capacity);chomp (input); +free (winput);if (!echo)WriteFile (err,"\r\n" ,2 , &len,NULL );
Signature · 1 line
1.7.5.4
OpenVPN output is not always a console.
I am not sure this patch is valid.
Quoted 81 lines · Heiko Hund
This patch makes openvpn read unicode from the console and convert the input to UTF-8. And then display UTF-8 output to the console correctly.
Signed-off-by Heiko Hund <[email protected]...>---
configure.ac | 1 +
openvpn.c | 4 ++++
win32.c | 8 +++++++-3 files changed, 12 insertions(+), 1 deletions(-)configure.ac +1
-0@@ -343,6 +343,7 @@ case "$host" in OPENVPN_ADD_LIBS(-lcrypt32) OPENVPN_ADD_LIBS(-liphlpapi) OPENVPN_ADD_LIBS(-lwinmm) + OPENVPN_ADD_LIBS(-lshell32) ;; *-*-dragonfly*) AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFlyBSD?])openvpn.c +4
-0@@ -131,6 +131,10 @@ main (int argc, char *argv[]) return 1; #endif +#ifdef TARGET_WIN32 + SetConsoleOutputCP (CP_UTF8); +#endif + CLEAR (c); /* signify first time for components which canwin32.c +7
-2@@ -763,6 +763,7 @@ get_console_input_win32 (const char *prompt, const bool echo, char *input, const bool is_console = (GetFileType (in) == FILE_TYPE_CHAR); DWORD flags_save = 0; int status = 0; + WCHAR *winput; if (is_console) {@@ -777,10 +778,15 @@ get_console_input_win32 (const char *prompt, const bool echo, char *input, const is_console = 0; } - status = ReadFile (in, input, capacity, &len, NULL); + winput = malloc (capacity * sizeof (WCHAR)); + if (winput == NULL) + return false; + status = ReadConsoleW (in, winput, capacity, &len, NULL); + WideCharToMultiByte (CP_UTF8, 0, winput, len, input, capacity, NULL, NULL); string_null_terminate (input, (int)len, capacity); chomp (input); + free (winput); if (!echo) WriteFile (err, "\r\n", 2, &len, NULL); --1.7.5.4
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 1 line · On Wednesday 23 November 2011 14:55:57 Alon Bar-Lev wrote:
OpenVPN output is not always a console.
What output are you concerned about? Log file is fine, as much as management interface.
Regards
Heiko
Signature · 8 lines
Heiko Hund | Software Engineer | Phone +49-721-25516-237 | Fax -200 Astaro a Sophos Company | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany Commercial Register: Mannheim HRA 702710 | Headquarter Location: Karlsruhe Represented by the General Partner Astaro Verwaltungs GmbH Amalienbadstraße 41 Bau 52 | 76227 Karlsruhe | Germany Commercial Register: Mannheim HRB 708248 | Executive Board: Gert Hansen, Markus Hennig, Jan Hichert, Günter Junk, Dr. Frank Nellissen
Quoted 8 lines · Heiko Hund
Quoted 1 line · On Wednesday 23 November 2011 14:55:57 Alon Bar-Lev wrote:
OpenVPN output is not always a console.
What output are you concerned about? Log file is fine, as much as management interface.
Regards
Heiko
Pipes when run as service.
Quoted 1 line · On Wednesday 23 November 2011 15:43:04 Alon Bar-Lev wrote:
Pipes when run as service.
Good one! I'll post an updated patch.
Regards
Heiko
Signature · 8 lines
Heiko Hund | Software Engineer | Phone +49-721-25516-237 | Fax -200 Astaro a Sophos Company | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany Commercial Register: Mannheim HRA 702710 | Headquarter Location: Karlsruhe Represented by the General Partner Astaro Verwaltungs GmbH Amalienbadstraße 41 Bau 52 | 76227 Karlsruhe | Germany Commercial Register: Mannheim HRB 708248 | Executive Board: Gert Hansen, Markus Hennig, Jan Hichert, Günter Junk, Dr. Frank Nellissen
PATCH v2 1/1 Windows UTF-8 input/output
In reply to Heiko HundThis patch makes openvpn read unicode from the console and convert the input to UTF-8. And then display UTF-8 output to the console correctly.
--- configure.ac | 1 + openvpn.c | 4 ++++ win32.c | 14 +++++++++++++- 3 files changed, 18 insertions(+), 1 deletions(-)
configure.ac +1 -0
@@ -343,6 +343,7 @@ case "$host" in OPENVPN_ADD_LIBS(-lcrypt32) OPENVPN_ADD_LIBS(-liphlpapi) OPENVPN_ADD_LIBS(-lwinmm) + OPENVPN_ADD_LIBS(-lshell32) ;; *-*-dragonfly*) AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFlyBSD?])
openvpn.c +4 -0
@@ -131,6 +131,10 @@ main (int argc, char *argv[])return 1 ;#endif +#ifdef TARGET_WIN32 +SetConsoleOutputCP (CP_UTF8 ); +#endif +CLEAR (c);/* signify first time for components which can
win32.c +13 -1
@@ -763,6 +763,7 @@ get_console_input_win32 (const char *prompt, const bool echo, char *input, constbool is_console = (GetFileType (in) ==FILE_TYPE_CHAR );DWORD flags_save =0 ;int status =0 ; +WCHAR *winput;if (is_console) {
@@ -777,7 +778,18 @@ get_console_input_win32 (const char *prompt, const bool echo, char *input, const is_console =0 ; } - status =ReadFile (in, input, capacity, &len,NULL ); +if (is_console) + { + winput =malloc (capacity *sizeof (WCHAR )); +if (winput ==NULL ) +return false; + + status =ReadConsoleW (in, winput, capacity, &len,NULL ); +WideCharToMultiByte (CP_UTF8 ,0 , winput, len, input, capacity,NULL ,NULL ); +free (winput); + } +else + status =ReadFile (in, input, capacity, &len,NULL );string_null_terminate (input, (int )len, capacity);chomp (input);
Signature · 1 line
1.7.5.4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 8 lines · Heiko Hund
This patch makes openvpn read unicode from the console and convert the input to UTF-8. And then display UTF-8 output to the console correctly.
Signed-off-by Heiko Hund <[email protected]...> --- configure.ac | 1+
openvpn.c| 4 ++++win32.c| 14 +++++++++++++- 3 files
changed, 18 insertions(+), 1 deletions(-)
ACKed and applied to master branch on -testing and -stable.
commit 6ba68180b89e0290855f70832243fc9b4370e4d2
Author: Heiko Hund <[email protected]...> Date: Wed Nov 23 19:08:34 2011 +0100
Windows UTF-8 input/output
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: David Sommerseth <[email protected]...>
Signed-off-by: David Sommerseth <[email protected]...>kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk85asMACgkQDC186MBRfroynACfQNt0I34bvNV6r5VBmqkmFF/k /LYAniC/Ch7k86CBGPRCRm284oaxuoaA
=qiCa
-----END PGP SIGNATURE-----