Java中,蚂蚁错误:编码不可映射的Cp1252字符 [英] Java, Ant error: unmappable character for encoding Cp1252

查看:3047
本文介绍了Java中,蚂蚁错误:编码不可映射的Cp1252字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java,Eclipse和蚂蚁在我的项目。我有一些Java code,我需要编辑和在其中添加一些UTF-8字符。 previously我的build.xml有:它工作得很好。现在添加这些UTF-8字符,当我尝试运行后,它会引发错误:无法映射的字符编码​​的Cp1252

I am using Java, Eclipse and Ant in my project. I had some Java code that I needed to edit and add some UTF-8 chars in them. Previously my build.xml had: And it worked fine. Now after adding those UTF-8 chars when I try to run, it throws "error: unmappable character for encoding Cp1252"

谁能告诉我什么是修复?我试图改变编码设置为UTF-8,在的Cp1252的XML,但没有运气。

Could anyone please tell me what is the fix? I tried changing the encoding to UTF-8 and Cp1252 in the xml but with no luck.

我使用JRE7,开普勒的Eclipse和Ant 4.11。

I'm using JRE7, Eclipse Kepler and Ant 4.11.

推荐答案

这可能会非常棘手简单地改变标榜编码不弥补的事实,有文件中的字节不能使用UTF-理解8间pretation。在蚂蚁,您将需要更新的javac 任务添加一个编码一样,< javac的...编码=UTF-8>

This can be tricky simply changing the "advertised" encoding does not make up for the fact that there are bytes in the file that cannot be understood using a UTF-8 interpretation. In Ant you will need to update the javac task to add an encoding like, <javac ... encoding="utf-8">

请确保在Eclipse中文件的编码也是UTF-8,因为有些CP1252字符不能直接映射到UTF-8两种。你可能会想,以保持使用单一的编码整个项目。否则,编译器将看到不同的编码时,它只希望之一。

Make sure that the file encoding in Eclipse is also UTF-8 because some cp1252 characters to not directly map into UTF-8 either. You will probably want to maintain your entire project using a single encoding. Otherwise the compiler will be seeing different encodings when it only expects one.

这篇关于Java中,蚂蚁错误:编码不可映射的Cp1252字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆