Android Studio:用于编码UTF-8的不可映射字符(Android Studio : unmappable character for encoding UTF-8)
将我的项目从eclipse导入到android studio后,我遇到以下错误:
Error: unmappable character for encoding UTF-8
Android Studio :0.5.8
After importing my project from eclipse into android studio i have got the following error :
Error: unmappable character for encoding UTF-8
Android Studio : 0.5.8
原文:https://stackoverflow.com/questions/23677855
更新时间:2019-11-20 22:03
最满意答案
我有同样的问题,因为有文件与Windows-1251编码和西里尔语注释。 在基于IntelliJ IDEA的Android Studio中,您可以通过两种方式解决此问题:
a)将文件编码转换为UTF-8或
b)在build.gradle脚本中设置正确的文件编码:
android {
...
compileOptions.encoding = 'windows-1251' // write your encoding here
...
要转换文件编码,请使用IDE右下角的菜单。 首先选择正确的文件编码 - >按重新加载 - >选择UTF-8 - >按转换 。
另请阅读这个使用UTF-8,Luke! IntelliJ IDEA中的文件编码
I had the same problem because there was files with windows-1251 encoding and Cyrillic comments. In Android Studio which is based on IntelliJ IDEA you can solve it in two ways:
a) convert file encoding to UTF-8 or
b) set the right file encoding in your build.gradle script:
android {
...
compileOptions.encoding = 'windows-1251' // write your encoding here
...
To convert file encoding use the menu at the bottom right corner of IDE. Select right file encoding first -> press Reload -> select UTF-8 -> press Convert.
2015-04-06
相关问答
这听起来像你有两个选择: 使用命令行参数调用生成器来生成UTF-8,而不是默认使用的任何东西。 (你没有说这个文件实际来自哪里,但我认为这个世代在你的控制之下......) 改变Netbeans处理文件的方式,告诉它它究竟是什么编码 就我个人而言,如果可能的话,我倾向于第一种选择 - UTF-8是一种很好的“一切都支持它”编码 It sounds like you have two options: Call the generator using a command-line parameter
...
我有同样的问题,因为有文件与Windows-1251编码和西里尔语注释。 在基于IntelliJ IDEA的Android Studio中,您可以通过两种方式解决此问题: a)将文件编码转换为UTF-8或 b)在build.gradle脚本中设置正确的文件编码: android {
...
compileOptions.encoding = 'windows-1251' // write your encoding here
...
要转换文件编码,请使用IDE右下角的菜
...
既然你已经在Visual Studio,为什么不只是写代码? foreach (var f in new DirectoryInfo(@"...").GetFiles("*.cs", SearchOption.AllDirectories)) {
string s = File.ReadAllText(f.FullName);
File.WriteAllText (f.FullName, s, Encoding.UTF8);
}
只有三行代码! 我相信你可以在不到一分钟内写下来:-) S
...
使用“\ uxxxx”转义格式。 根据维基百科 ,版权符号是unicode U + 00A9,所以你的行应该是: String copyright = "\u00a9 2003-2008 My Company. All rights reserved.";
Use the "\uxxxx" escape format. According to Wikipedia, the copyright symbol is unicode U+00A9 so your line should read:
...
Character没有UTF-8表示的直接(公共)访问器。 Character.swift中有一些内部方法处理UTF-8字节,但公共内容是在String.UTF8View中实现的 。 因此String(myChar).utf8.count是获取UTF-8表示字符长度的正确方法。 Character has no direct (public) accessor to its UTF-8 representation. There are some internal methods in Chara
...
尝试这个 HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
JSONObject myjson= new JSONObject();
myjson.put("name", "ÅsdfÖ"));
httppost.setEntity(new StringEntity(myjson.toString(), "UTF-8
...
源脚本的字符编码与从磁盘和其他源读取的文件执行的I / O之间存在差异。 像# encoding: utf-8这样的神奇线条告诉Ruby,源文件本身具有普通ASCII范围之外的UTF-8编码字符。 这使Ruby可以正确解释源文件中的固定字符串和多字节字符。 对于I / O流,您需要告诉Ruby如何解释传入/传出数据。 IO.new及其相关方法采用可选参数来说明传入/传出数据流编码是什么。 从磁盘,套接字或管道读取的YAML,JSON,HTML,XML和其他文件类型如果不是纯ASCII,则容易受到编
...
我会选择第二个片段,UTF-8是每个平台支持的标准字符编码之一,因此异常实际上永远不会发生。 将它进一步传播是没有意义的。 如果您正在开发API 19或更高版本,您也可以使用 strOriginal.getBytes(StandardCharsets.UTF_8)
这不会引发异常。 I would go for the second snippet, UTF-8 is one of the standard character encodings supported by every platf
...
我有同样的问题。 这就是我解决它的方式: 当我启动ant release ,输出中有这一行: [setup] Importing rules file: tools/ant/ant_rules_r3.xml 。 我编辑了ant_rules_r3.xml并将“ascii”替换为“UTF8”。 I had the same problem. This is how I solved it: When I launch ant release, there is this line in the out
...
我有同样的问题。 我解决了它,如下所示。 但是,我不保证解决方案是坚如磐石的。 试一试: library(dplyr)
library(sqldf)
# Modifying built-in mtcars dataset
mtcars$test
c("č", "ž", "š", "č", "ž", "š", letters) %>%
enc2utf8(.)
mtcars$češćžä
c("č", "ž", "š", "č", "ž", "š", letters
...