.NET StringReader 或 TextAsset 根本不读取某些字符
我的代码:
StringReader tr = null;
TextAsset data = (TextAsset)Resources.Load("data.ext", typeof(TextAsset));
tr = new StringReader(data.text);
sTemp = tr.ReadLine();
Debug.Log(sTemp);
data.ext 文件:
00!%%%£r!%%%£122222230e0e01255
我的输出:
00!%%%r!%%%122222230e0e01255
如您所见,StringReader(或可能是 TextAsset)似乎不喜欢 £ 字符。我认为可能有一些我不知道的奇怪的转义类型的角色 我查看了 .net 和 unity 文档,但找不到任何解释或任何有关特殊字符的提及。
这完全把我难住了。我正在使用 mono .NET 的 Unity3D 中进行编译。我可能会使用官方 .NET 编译器进行一些测试。
感谢您的帮助。
My code:
StringReader tr = null;
TextAsset data = (TextAsset)Resources.Load("data.ext", typeof(TextAsset));
tr = new StringReader(data.text);
sTemp = tr.ReadLine();
Debug.Log(sTemp);
data.ext file:
00!%%%£r!%%%£122222230e0e01255
My output:
00!%%%r!%%%122222230e0e01255
As you can see StringReader (or possibly TextAsset) doesn't seem to like the £ character. I thought there might be some strange escape type of character which I didn't know about
I have looked on the .net and unity docs, but I can't find any explanation or any mention about special characters.
This one has me completely stumped. I am compiling in Unity3D which uses mono .NET. I might do some tests using the official .NET compiler.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了解决方案。我用 UTF8 编码保存了我的文本文件,现在一切都很好。无需更改代码。
Found the solution. I saved my text file with UTF8 encoding and now everything is fine. No changes to the code were needed.