diff --git a/src/luaengineio/luaengine/LuaEngineIO.cpp b/src/luaengineio/luaengine/LuaEngineIO.cpp
index 434762d..7b4808c 100644
--- a/src/luaengineio/luaengine/LuaEngineIO.cpp
+++ b/src/luaengineio/luaengine/LuaEngineIO.cpp
@@ -100,7 +100,7 @@ int LuaEngineIO::eIORead(lua_State *L_p)
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QIODevice")) {
const QByteArray readData = ((QIODevice*)pointer)->read(getVariant(L_p, 2).toLongLong());
- pushVariant(L_p, readData);
+ pushVariant(L_p, QString::fromUtf8(readData));
return 1;
}
}
@@ -115,7 +115,7 @@ int LuaEngineIO::eIOReadAll(lua_State *L_p)
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QIODevice")) {
const QByteArray readData = ((QIODevice*)pointer)->readAll();
- pushVariant(L_p, readData);
+ pushVariant(L_p, QString::fromUtf8(readData));
return 1;
}
}
@@ -130,7 +130,7 @@ int LuaEngineIO::eIOReadLine(lua_State *L_p)
if (pointer != NULL) {
if (((QObject*)pointer)->inherits("QIODevice")) {
const QByteArray readData = ((QIODevice*)pointer)->readLine();
- pushVariant(L_p, readData);
+ pushVariant(L_p, QString::fromUtf8(readData));
return 1;
}
}
diff --git a/tests/network/network.lua b/tests/network/network.lua
new file mode 100644
index 0000000..b758fe9
--- /dev/null
+++ b/tests/network/network.lua
@@ -0,0 +1,31 @@
+local globalLabel
+
+function main()
+ -- Window
+ mainWindow = createMainWindow("LE TCP Test")
+ local mainLayout = createLayout(VerticalLayout, mainWindow)
+
+ local socket = createTcpSocket()
+ connect(socket, "connected()", "socketConnected")
+ connect(socket, "readyRead()", "socketReadyRead")
+ socketConnect(socket, "syping.de:80")
+
+ globalLabel = createLabel("Connecting...", mainLayout)
+
+ -- Show Window
+ setWidgetSize(mainWindow, 650, 450)
+ showWidget(mainWindow, ShowDefault)
+ return GuiExecuted
+end
+
+function socketConnected(socket)
+ setObjectText(globalLabel, "Connected!")
+ eIOWrite(socket, "GET /luaenginetest.html HTTP/1.1\r\nHost: www.syping.de\r\nUser-Agent: LuaEngine\r\nConnection: close\r\n\r\n")
+ socketFlush(socket)
+end
+
+function socketReadyRead(socket)
+ setObjectText(globalLabel, "Reading...")
+ local readData = eIOReadAll(socket)
+ setObjectText(globalLabel, "" .. readData)
+end