Skip to content

无法加载编码为ANSI的数据表文件 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mutouzdl opened this issue Mar 14, 2018 · 2 comments
Closed

无法加载编码为ANSI的数据表文件 #19

mutouzdl opened this issue Mar 14, 2018 · 2 comments

Comments

@mutouzdl
Copy link

按照官网的教程:http://gameframework.cn/archives/235
数据表文件需要保存为ANSI编码,但实际上,当我的数据表文件里包含中文的时候(在注释行里),加载文件会失败(不报错,但是加载不出数据)。

最终是将文件转换为UTF-8才能读取成功,请问是为什么呢?

Game Framework版本:3.1.1
Unity3D版本:2017.3

@EllanJiang
Copy link
Owner

原因:从 Unity 2017 开始,一个 ANSI 格式的文本加载为 TextAsset 后,直接取其 textAsset.text 内容会是空的,Unicode 或者 UTF-8 格式不受影响,在之前版本的 Unity 中,即使文本是 ANSI,textAsset.text 也是能取出内容的。
解决方法:

  1. 使用 Unicode 或者 UTF-8 格式存储文本。
  2. 使用 textAsset.bytes 取出字节流,自行转换成文本。

@mutouzdl
Copy link
Author

明白,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants