Commit e95939e5 authored by Hugo Beauzée-Luyssen's avatar 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's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent f729d67b
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#endif #endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_charset.h>
#include "../vlc.h" #include "../vlc.h"
#include "../libs.h" #include "../libs.h"
...@@ -140,6 +141,14 @@ static int vlclua_console_read( lua_State *L ) ...@@ -140,6 +141,14 @@ static int vlclua_console_read( lua_State *L )
return 1; 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[] = { ...@@ -148,6 +157,7 @@ static const luaL_Reg vlclua_win_reg[] = {
{ "console_init", vlclua_console_init }, { "console_init", vlclua_console_init },
{ "console_wait", vlclua_console_wait }, { "console_wait", vlclua_console_wait },
{ "console_read", vlclua_console_read }, { "console_read", vlclua_console_read },
{ "console_write", vlclua_console_write },
{ NULL, NULL } { NULL, NULL }
}; };
......
...@@ -124,7 +124,7 @@ function host() ...@@ -124,7 +124,7 @@ function host()
local function write_console( client, data ) local function write_console( client, data )
-- FIXME: this method shouldn't be needed. vlc.net.write should -- FIXME: this method shouldn't be needed. vlc.net.write should
-- just work -- just work
io.write(data or client.buffer) vlc.win.console_write(data or client.buffer)
return string.len(data or client.buffer) return string.len(data or client.buffer)
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment