开发者

How to force Visual Studio to honor the BOM at the start of a UTF-8 encoded CSS file?

开发者 https://www.devze.com 2022-12-19 06:15 出处:网络
Apparently, when Visual Studio 2008开发者_如何学运维 (SP1) opens a CSS file, it doesn\'t recognize the UTF8 BOM marker as a BOM, but instead interprets it as text (first three characters show up as ï

Apparently, when Visual Studio 2008开发者_如何学运维 (SP1) opens a CSS file, it doesn't recognize the UTF8 BOM marker as a BOM, but instead interprets it as text (first three characters show up as , but shouldn't be visible). While VS normally doesn't save the CSS files with a BOM, I'd expect the IDE to recognize and respect the BOM when it's there.

This may be a bug with Visual Studio, however, does anyone know a workaround?


This appeared to be a bug in Visual Studio 2008 SP1. Once it misinterprets the CSS file, it will continue misinterpreting it. Signs on the sand were, too, that rightclicking and selecting "Open With" did not work for any internal editor.

Closing Visual Studio and reopening it didn't work. What worked eventually was:

  • Rightclick the CSS file, select Open With and select CSS Source Editor With Encoding
  • Click Set as Default, then click OK. Nothing will happen.
  • Close all editors. Close Visual Studio
  • Reopen Visual Studio and your solution or project.
  • Double click the CSS file. It will ask for the encoding. Select Auto. It should now open correctly.
  • Rightclick again and set the default editor back to CSS Source Editor (otherwise you'll always have to select the encoding manually).

Or in short: associate with "With Encoding", restart VS, open CSS correctly with encoding "Auto", re-associate with default CSS Editor, done.

0

精彩评论

暂无评论...
验证码 换一张
取 消