Visual Studio 2026 新建axaml编码是gbk 中文运行乱码

在解决方案目录下 新建.editorconfig文件

内容如下

# 让 Visual Studio 所有文件都默认使用 UTF-8(带 BOM)
root = true

[*]
charset = utf-8 # 强制所有文件保存为 UTF-8 带签名
end_of_line = crlf # Windows 换行
insert_final_newline = true # 文件末尾自动加换行
trim_trailing_whitespace = true

# C# 文件
[*.cs]
charset = utf-8
indent_style = space
indent_size = 4

# XAML 文件
[*.xaml]
charset = utf-8
indent_style = space
indent_size = 4

# JSON / XML 配置文件
[*.json]
charset = utf-8
[*.xml]
charset = utf-8

posted @ 2025-12-19 17:39  simadi  阅读(0)  评论(0)    收藏  举报