简体   繁体   English

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

[英]Which encoding should I use for my Android Studio project?

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? 有什么理由我应该使用其中一个而不是另一个?

Since gradle and Android studio both use UTF-8, you should consider using that. 由于gradle和Android studio都使用UTF-8,因此您应该考虑使用它。 It's a good encoding too as it's based on unicode charset. 它也是一个很好的编码,因为它基于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. 单击文件 - >设置(或单击Ctrl + Alt + S),然后在Androd Studio中找到文件编码 See the image below as a reference. 请参阅下图作为参考。

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 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. 您还可以在Android工作室的右下角看到文件的当前编码。 You can also change it there. 你也可以在那里改变它。 See the image below. 见下图。

IDE编码

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编码测试开发环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应在Android项目中使用哪个compileSdkVersion? - Which compileSdkVersion should I use in my android project? 我应该在项目中使用哪个Android Gradle插件版本? - Which Android Gradle Plugin version should I use in my project? 对于 Android Studio 项目,我应该将哪些文件添加到 SVN 忽略? - Which files should I add to SVN ignore for an Android Studio project? Android Studio Java-我应该使用哪个修饰符? - Android Studio Java - Which modifier should I use? 我应该安装哪个 Java JDK 来使用 Android Studio - Which Java JDK should I install for the use of Android Studio Android Studio和Eclipse-我应该使用哪一个? - Android Studio and Eclipse - which one I should use? 我应使用哪个AIR版本将应用程序移植到Android? - Which version of AIR should I use to port my application to Android? Android Studio 项目编码错误 - Android Studio Project Encoding Error 什么时候应该在Android Studio中使用Android Project View的每个选项? - When should I use each option of Android Project View at Android Studio? 当我在 Android Studio 中创建一个新项目时,我应该根据项目类型选择哪个 API 级别作为最低 SDK? - When I create a new project in Android Studio, which API level should I choose according to project type as the minimum SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM