这是我获取文本的方式:
switch(lsel) {
case 0:
luafile = "lua/example.lua";
break;
case 1:
luafile = "lua/example2.lua";
break;
}
ifstream f(luafile);
f >> noskipws; //don't want to skip spaces !
vector<unsigned char> v(
(istream_iterator<unsigned char>(f))
, (istream_iterator<unsigned char>()));
LBytes lexing = LBytes(bytes, 2);
lexing += lselect;
lexing += LBytes(v.data(), v.size());
//f.close();
return lexing;
然后我在 C# 中处理它:
int docnumber = BitConverter.ToInt32(Core.ncon.ArrayRead, 2);
Log(docnumber.ToString());
char[] valx = new char[Core.ncon.ArrayReadSize - 2 - sizeof(int)];
Array.Copy(Core.ncon.ArrayRead, 2, valx, 0, Core.ncon.ArrayReadSize - 2 - sizeof(int));
Core.lua[docnumber] = new string(valx);
并放入 RichTextBox
private void confListBox_SelectedIndexChanged(object sender, EventArgs e) {
if (confListBox.SelectedIndex < 10) {
string one = Core.lua[confListBox.SelectedIndex];
this.luaTextBox.Text = one;
}
现在一个包含字符串:
"\0\0\0\0io.write(\"Please enter your name: \")\n-- name = io.read() -- read input from user\nname = \"someone\"\nprint (\"Hi \" .. name .. \", enjoy hacking with Lu"
和文本将是""
这些\0\0\0\0
东西是从哪里来的?