如何为 SVN 文件和 Eclipse 设置字符集编码属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6856305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:43:38  来源:igfitidea点击:

How to set charset encoding property for SVN File and Eclipse

javaeclipsesvnutf-8internationalization

提问by harrybvp

I have a file which has international characters (UTF-8),How to set this Encoding type as a part of svn property and how do i ensure that it overrides automatically default encoding in eclipse i.e eclipse shoul automatically set UTF-8 encoding based on the svn property (may be mime-type)

我有一个包含国际字符 (UTF-8) 的文件,如何将此编码类型设置为 svn 属性的一部分,以及如何确保它自动覆盖 eclipse 中的默认编码,即 eclipse 应自动设置 UTF-8 编码基于svn 属性(可能是 MIME 类型)

回答by cabo

svn propset svn:mime-type "text/plain; charset=UTF-8" filename...

svn propset svn:mime-type "text/plain; charset=UTF-8" 文件名...

回答by user8345631

I had same problem, but solved by setting below:

我遇到了同样的问题,但通过以下设置解决了:

Set Encoding in Eclipse: Project --> Properties --> Resources --> Text File Encoding --> Other (UTF-8)

在 Eclipse 中设置编码:项目 --> 属性 --> 资源 --> 文本文件编码 --> 其他 (UTF-8)

回答by Chris M

I was struggling with this for a while, and have found another solution. If you're using maven you can set the encoding in the pom. see https://maven.apache.org/general.html.

我为此苦苦挣扎了一段时间,并找到了另一种解决方案。如果您使用的是 maven,则可以在 pom.xml 中设置编码。见https://maven.apache.org/general.html

After you've added this, when you do a Maven > Update Project (Alt+ F5) it will set the correct encoding for the project.

添加此内容后,当您执行 Maven > Update Project ( Alt+ F5) 时,它将为项目设置正确的编码。

<project>
  ...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  ...
</project>

回答by Nicolas

In SVN, I don't know but you can set text file encoding on each file individually: right-click on the file, go to properties and in the resource submenu check 'Other' for Text File Encoding.

在 SVN 中,我不知道,但您可以单独为每个文件设置文本文件编码:右键单击文件,转到属性并在资源子菜单中选中“其他”以获取文本文件编码。