Skip to content
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

代码生成器生成的文件在MacOS下中文显示乱码 #163

Open
haoyk opened this issue Jul 19, 2023 · 4 comments
Open

代码生成器生成的文件在MacOS下中文显示乱码 #163

haoyk opened this issue Jul 19, 2023 · 4 comments

Comments

@haoyk
Copy link

haoyk commented Jul 19, 2023

通过代码生成器生成的文件如AppService、Dto中有中文注释的,在MacOS下会是乱码,Windows下没有问题。
经过排查发现是生成的文件编码默认为ANSI格式,建议修改为UTF-8.

@wakuflair
Copy link
Member

ABPHelper使用File.WriteAllTextAsync生成文件,该方法默认使用的是UTF-8(无BOM),所以理论上应该不会产生乱码。

你的DTO文件用的什么编码?我怀疑在解析的时候就已经乱了。

@blackWins
Copy link
Contributor

这个和系统默认编码有关系不,如系统默认编码是GB2312。

ABPHelper使用File.WriteAllTextAsync生成文件,该方法默认使用的是UTF-8(无BOM),所以理论上应该不会产生乱码。

你的DTO文件用的什么编码?我怀疑在解析的时候就已经乱了。

@wakuflair
Copy link
Member

文档写的使用UTF-8,和系统编码应该没关系。

@wakuflair
Copy link
Member

如果DTO源码使用的GB2312,有可能会导致这个错误,因为读取的时候也是按照UTF-8

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

3 participants