Commit 633361ef authored by akharlov's avatar akharlov
Browse files

fix unicode characters support in DoString

parent 25c51407
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.IO; using System.IO;
using System.Text;
using NLua.Extensions; using NLua.Extensions;
namespace NLua namespace NLua
...@@ -384,7 +385,8 @@ namespace NLua ...@@ -384,7 +385,8 @@ namespace NLua
public static int LuaLLoadBuffer (LuaState luaState, string buff, string name) public static int LuaLLoadBuffer (LuaState luaState, string buff, string name)
{ {
return LuaCore.LuaNetLoadBuffer (luaState, buff, (uint)0, name); var bytes = Encoding.UTF8.GetBytes(buff);
return LuaCore.LuaNetLoadBuffer (luaState, bytes, (uint)bytes.Length, name);
} }
public static int LuaLLoadBuffer (LuaState luaState, byte [] buff, string name) public static int LuaLLoadBuffer (LuaState luaState, byte [] buff, string name)
......
...@@ -157,6 +157,13 @@ namespace NLuaTest ...@@ -157,6 +157,13 @@ namespace NLuaTest
return Convert.ToString (UnicodeChar); return Convert.ToString (UnicodeChar);
} }
} }
public static string UnicodeStringRussian
{
get
{
return "Файл";
}
}
/* /*
* Tests capturing an exception * Tests capturing an exception
*/ */
...@@ -2065,6 +2072,17 @@ namespace NLuaTest ...@@ -2065,6 +2072,17 @@ namespace NLuaTest
} }
} }
[Test]
public void TestUnicodeCharsInDoString()
{
using (Lua lua = new Lua ()) {
lua.DoString("res = 'Файл'");
string res = (string)lua["res"];
Assert.AreEqual(LuaTests.UnicodeStringRussian, res);
}
}
[Test] [Test]
public void TestCoroutine () public void TestCoroutine ()
{ {
......
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