简体   繁体   English

错误:编码 UTF-8 用于数据绑定的不可映射字符

[英]error: unmappable character for encoding UTF-8 for databinding

I am getting such an error, I changed uf8 I tried everything that is general What is this problem?我收到这样的错误,我更改了 uf8 我尝试了所有通用的方法 这是什么问题?

    app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\com\cd\statussaver\databinding\ItemsFileViewBinding.java:23: error: unmappable character for encoding UTF-8
  public final ImageView iv�mage;

 protected ItemsFileViewBinding(Object _bindingComponent, View _root, int _localFieldCount,
  ImageView ivPlay, ImageView iv�mage, RelativeLayout rlMain, TextView tvFileName) {
super(_bindingComponent, _root, _localFieldCount);
this.ivPlay = ivPlay;
this.iv�mage = iv�mage;
this.rlMain = rlMain;
this.tvFileName = tvFileName;

Let me do some guesswork.让我做一些猜测。

In the editor where you wrote the code (and where you can read the text), what's the encoding that this editor uses?在您编写代码的编辑器中(以及您可以阅读文本的位置),该编辑器使用的编码是什么? Or, open your java source in Notepad++, make sure that everything is readable, and look at the status line - does it say "UTF-8"?或者,在 Notepad++ 中打开您的 java 源代码,确保所有内容都可读,然后查看状态行 - 它是否显示“UTF-8”? Probably not.可能不是。 I guess it's some 8-bit encoding like ISO-8859-nn or Windows CPnnnn.我猜这是一些 8 位编码,例如 ISO-8859-nn 或 Windows CPnnnn。

And when compiling with your build framework (maven, gradle, javac, whatever), did you specify that very same encoding to be assumed for your source files?在使用构建框架(maven、gradle、javac 等)进行编译时,您是否为源文件指定了相同的编码? Probably not, as the error message says that it failed reading the source file as UTF-8 - here I see that the compiler assumed UTF-8 encoding.可能不是,因为错误消息说它无法将源文件读取为 UTF-8 - 在这里我看到编译器假定 UTF-8 编码。

From your name, I guess your computer might be localized for Turkish, where there is a special uppercase I with a dot that might cause the encoding troubles.根据您的名字,我猜您的计算机可能已本地化为土耳其语,其中有一个带有点的特殊大写字母 I,可能会导致编码问题。

If you stay within the ASCII character set, you'll never experience these encoding troubles, but also never detect encoding mis-configurations.如果您停留在 ASCII 字符集中,您将永远不会遇到这些编码问题,也永远不会检测到编码错误配置。

To solve the problem, I see two possibilities:为了解决这个问题,我看到了两种可能性:

  • Transcode all your source files from their current encoding to UTF-8, configure your source code editors to use this encoding, and have the build framework assume UTF-8 (you probably have that third part already done).将所有源文件从当前编码转码为 UTF-8,配置源代码编辑器以使用此编码,并让构建框架假定 UTF-8(您可能已经完成了第三部分)。
  • Find out the encoding that your source files really use, and configure that build framework to assume that encoding for the source files.找出您的源文件真正使用的编码,并配置该构建框架以假定源文件的编码。

As all the industry is moving towards UTF-8, I'd recommend to go through the pain of the first possibility.由于整个行业都在朝着 UTF-8 发展,我建议通过第一种可能性的痛苦来 go。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM