我应该为Android Studio项目使用哪种编码?

时间:2021-12-25 04:16:18

I had a problem similar to this one: Android Studio 1.2 - Project encoding mismatches by default

我遇到了类似这样的问题:Android Studio 1.2 - 默认情况下项目编码不匹配

The Android Studio project & gradle encoding is now set to windows-1252 instead of UTF-8.

Android Studio项目和gradle编码现在设置为windows-1252而不是UTF-8。

Is there any reason I should be using one of these over the other?

有什么理由我应该使用其中一个而不是另一个?

2 个解决方案

#1


Since gradle and Android studio both use UTF-8, you should consider using that. It's a good encoding too as it's based on unicode charset.

由于gradle和Android studio都使用UTF-8,因此您应该考虑使用它。它也是一个很好的编码,因为它基于unicode charset。

There has also been some talk on whether they should enforce UTF-8 or not in the future, so you should start changing to UTF-8 asap :)

还有一些关于他们是否应该在未来强制执行UTF-8的讨论,所以你应该开始更改为UTF-8尽快:)

You can change your encoding as follows below.

您可以按照以下方式更改编码。

Click File -> Settings (or click Ctrl + Alt + S) and find File Encodings in your Androd Studio. See the image below as a reference.

单击文件 - >设置(或单击Ctrl + Alt + S),然后在Androd Studio中找到文件编码。请参阅下图作为参考。

Now you have three options

现在你有三个选择

  • change UTF-8 to match other encoding
  • 更改UTF-8以匹配其他编码

  • or change project encoding to match UTF-8 since both Gradle and Android Lint use this (recommended)
  • 或更改项目编码以匹配UTF-8,因为Gradle和Android Lint都使用此(推荐)

  • Ignore the warning
  • 忽略警告

http://shrani.si/f/3V/p7/5xt1uxV/encoding.png

You can also see the current encoding of your file at the bottom right corner of Android studio. You can also change it there. See the image below.

我应该为Android Studio项目使用哪种编码?

您还可以在Android工作室的右下角看到文件的当前编码。你也可以在那里改变它。见下图。

#2


Localization to numerous languages requires Unicode, so use UTF-8.

对多种语言的本地化需要Unicode,因此请使用UTF-8。

BTW, it is possible that due to this reasoning nobody never tested the development environment with a non-Unicode encoding.

顺便说一句,由于这个推理,有可能没有人从未使用非Unicode编码测试开发环境。

#1


Since gradle and Android studio both use UTF-8, you should consider using that. It's a good encoding too as it's based on unicode charset.

由于gradle和Android studio都使用UTF-8,因此您应该考虑使用它。它也是一个很好的编码,因为它基于unicode charset。

There has also been some talk on whether they should enforce UTF-8 or not in the future, so you should start changing to UTF-8 asap :)

还有一些关于他们是否应该在未来强制执行UTF-8的讨论,所以你应该开始更改为UTF-8尽快:)

You can change your encoding as follows below.

您可以按照以下方式更改编码。

Click File -> Settings (or click Ctrl + Alt + S) and find File Encodings in your Androd Studio. See the image below as a reference.

单击文件 - >设置(或单击Ctrl + Alt + S),然后在Androd Studio中找到文件编码。请参阅下图作为参考。

Now you have three options

现在你有三个选择

  • change UTF-8 to match other encoding
  • 更改UTF-8以匹配其他编码

  • or change project encoding to match UTF-8 since both Gradle and Android Lint use this (recommended)
  • 或更改项目编码以匹配UTF-8,因为Gradle和Android Lint都使用此(推荐)

  • Ignore the warning
  • 忽略警告

http://shrani.si/f/3V/p7/5xt1uxV/encoding.png

You can also see the current encoding of your file at the bottom right corner of Android studio. You can also change it there. See the image below.

我应该为Android Studio项目使用哪种编码?

您还可以在Android工作室的右下角看到文件的当前编码。你也可以在那里改变它。见下图。

#2


Localization to numerous languages requires Unicode, so use UTF-8.

对多种语言的本地化需要Unicode,因此请使用UTF-8。

BTW, it is possible that due to this reasoning nobody never tested the development environment with a non-Unicode encoding.

顺便说一句,由于这个推理,有可能没有人从未使用非Unicode编码测试开发环境。