【问题标题】:How can I set the range of `file.autoGuessEncoding` in Visual Studio Code?如何在 Visual Studio Code 中设置 `file.autoGuessEncoding` 的范围?
【发布时间】:2018-01-16 09:14:19
【问题描述】:

例如,我可以在vimrc 中设置编码的范围和顺序。这样,它会自动按顺序猜测文件的编码。

set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

这在 Visual Studio Code 中可行吗?

【问题讨论】:

    标签: visual-studio-code vscode-settings


    【解决方案1】:

    您可以在 VS Code 中更改此设置:

    // When enabled, will attempt to guess the character set encoding when opening files. This setting can be configured per language too.
    "files.autoGuessEncoding": false,
    

    但是当您将其设置为例如"ucs-bom,utf-8",你会得到一个工具提示,上面写着Incorrect type. Expected "boolean".

    另一个文件编码相关的设置是这样的:

    // The default character set encoding to use when reading and writing files. This setting can be configured per language too.
    "files.encoding": "utf8"
    

    但有效值是这些(当您尝试设置其他内容时可以看到这些):

    "utf8", "utf8bom", "utf16le", "utf16be", "windows1252", "iso88591", "iso88593", "iso885915", "macroman", "cp437", "windows1256", "iso88596", "windows1257", "iso88594", "iso885914", "windows1250", "iso88592", "cp852", "windows1251", "cp866", "iso88595", "koi8r", "koi8u", "iso885913", "windows1253", "iso88597", "windows1255", "iso88598", "iso885910", "iso885916", "windows1254", "iso88599", "windows1258", "gbk", "gb18030", "cp950", "big5hkscs", "shiftjis", "eucjp", "euckr", "windows874", "iso885911", "koi8ru", "koi8t", "gb2312", "cp865", "cp850"
    

    所以不,我认为你不能在 VS Code 中做到这一点,至少在没有扩展的情况下不能。 (我不知道是否有这样的扩展可以实现这一点。)但请注意,这两个设置可以根据语言进行配置。

    这里是相关的 GitHub 问题,也许你应该权衡一下:

    【讨论】:

      猜你喜欢
      • 2018-04-25
      • 2016-07-06
      • 2018-01-21
      • 2015-09-17
      • 2021-07-09
      • 1970-01-01
      • 2020-04-21
      • 2021-09-18
      • 2017-05-25
      相关资源
      最近更新 更多