gpt4 book ai didi

c# - 来自 ifstream 的文本开始时带有 "\0\0\0

转载 作者:行者123 更新时间:2023-11-28 07:52:34 27 4
gpt4 key购买 nike

这是我获取文本的方式:

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 东西是从哪里来的?

最佳答案

您似乎在文本前添加了一些来自与文件不同来源的内容:

LBytes lexing = LBytes(bytes, 2);
lexing += lselect;
lexing += LBytes(v.data(), v.size());

我怀疑前两行贡献了零。

关于c# - 来自 ifstream 的文本开始时带有 "\0\0\0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13452396/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com