static int BufferToString(IntPtr L)
{
try
{
object o = CheckObject(L, 1);
if (o is byte[])
{
byte[] buff = (byte[])o;
LuaDLL.lua_pushlstring(L, buff, buff.Length);
}
else if (o is char[])
{
byte[] buff = System.Text.Encoding.UTF8.GetBytes((char[])o);
LuaDLL.lua_pushlstring(L, buff, buff.Length);
}
else if (o is string)
{
LuaDLL.lua_pushstring(L, (string)o);
}
else
{
LuaDLL.luaL_typerror(L, 1, "byte[] or char[]");
}
}
catch (Exception e)
{
LuaDLL.toluaL_exception(L, e);
}
return(1);
}