【GiraKoo】VS提示Some bytes have been replaced with the Unicode substitution character

【问题解决】VS提示Some bytes have been replaced with the Unicode substitution character

VS提示Some bytes have been replaced with the Unicode substitution character while loading file xxxxx with Unicode(UTF-8) encoding. Saving the file will not preserve the original file contents.
中文意思,是在打开xxxxx文件时,部分字符被替换成Unicode(UTF-8)格式,保存文件将会无法保留原来的内容(原来的内容将会被替换成Unicode)
Visual Studio报错提示

【背景】

在Visual Studio 2022版本中,打开非UTF-8格式的代码,会同时提示以上内容。从内容推断,应当是某个程序在打开文件时,对文件的编码进行了调整。导致问题发生。

【环境】

系统:Windows 10
开发环境:Visual Studio 2022

【解决思路】

找到有可能修改文件编码格式的可能性。包括VS自带的插件,工具。或者是系统的某些设定。
在控制面板中,有一个"使用Unicode UTF-8提供全球语言支持"。当文本未指定编码格式时,将默认作为UTF-8编码进行处理。这样会导致GB2312编码格式的文件被当做UTF-8进行解析。遇到无法解析的字符,将会报错。

【解决方案】

  1. 打开"控制面板"
  2. 选择"时钟与区域"
  3. 选择"区域",切换到"管理"Tab
  4. 点击"更改系统区域设置"
  5. 取消"Beta版:使用Unicode UTF-8提供全球语言支持"
  6. 重启电脑。
    设置图解
posted @   GiraKoo  阅读(214)  评论(6编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 上周热点回顾(2.17-2.23)
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
点击右上角即可分享
微信分享提示