Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
633361ef
Commit
633361ef
authored
Jan 17, 2017
by
akharlov
Browse files
fix unicode characters support in DoString
parent
25c51407
Changes
2
Hide whitespace changes
Inline
Side-by-side
Core/NLua/LuaLib/LuaLib.cs
View file @
633361ef
...
@@ -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
)
...
...
tests/LuaTests.cs
View file @
633361ef
...
@@ -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
()
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment