[vlc-commits] lua: console: Fix output of non ascii characters on win32

Hugo Beauzée-Luyssen git at videolan.org
Wed Mar 14 09:54:46 CET 2018


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Mar  9 17:31:39 2018 +0100| [e95939e55b534e21e57560efe460fcf3cc46bff4] | committer: Hugo Beauzée-Luyssen

lua: console: Fix output of non ascii characters on win32

refs #19874

(cherry picked from commit 0720cec581ae3cd6228edd8d6567ad5b30910027)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e95939e55b534e21e57560efe460fcf3cc46bff4
---

 modules/lua/libs/win.c          | 10 ++++++++++
 share/lua/intf/modules/host.lua |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/modules/lua/libs/win.c b/modules/lua/libs/win.c
index 14d6d30f78..7d0276331e 100644
--- a/modules/lua/libs/win.c
+++ b/modules/lua/libs/win.c
@@ -29,6 +29,7 @@
 #endif
 
 #include <vlc_common.h>
+#include <vlc_charset.h>
 
 #include "../vlc.h"
 #include "../libs.h"
@@ -140,6 +141,14 @@ static int vlclua_console_read( lua_State *L )
     return 1;
 }
 
+static int vlclua_console_write( lua_State *L )
+{
+    if( !lua_isstring( L, 1 ) )
+        return luaL_error( L, "win.console_write usage: (text)" );
+    const char* psz_line = luaL_checkstring( L, 1 );
+    utf8_fprintf( stdout, "%s", psz_line );
+    return 0;
+}
 
 /*****************************************************************************
  *
@@ -148,6 +157,7 @@ static const luaL_Reg vlclua_win_reg[] = {
     { "console_init", vlclua_console_init },
     { "console_wait", vlclua_console_wait },
     { "console_read", vlclua_console_read },
+    { "console_write", vlclua_console_write },
     { NULL, NULL }
 };
 
diff --git a/share/lua/intf/modules/host.lua b/share/lua/intf/modules/host.lua
index 1d84bbad94..7c99778319 100644
--- a/share/lua/intf/modules/host.lua
+++ b/share/lua/intf/modules/host.lua
@@ -124,7 +124,7 @@ function host()
     local function write_console( client, data )
         -- FIXME: this method shouldn't be needed. vlc.net.write should
         -- just work
-        io.write(data or client.buffer)
+        vlc.win.console_write(data or client.buffer)
         return string.len(data or client.buffer)
     end
 



More information about the vlc-commits mailing list