Java 1.7是否使用其他字符编码? [英] Does Java 1.7 use a different character encoding?

查看:47
本文介绍了Java 1.7是否使用其他字符编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将应用程序从Java 1.6迁移到Java 1.7.我们使用Java 1.7重新编译了代码,并在编译时收到一个错误,该错误是由于字符(Ó)引起的.

We are migrating our application from Java 1.6 to Java 1.7. We recompiled the code using Java 1.7 and received an error while compiling which was due to a character (an Ó).

Java 1.7中与字符有关的更改吗?我们的应用程序对传入文件进行了大量处理,然后将它们加载到数据库中,我想确保当我们升级到Java 1.7时,从java中读取文件以及对该内容的写入数据库不会导致某些结果.奇数字符转换.

Was there a change in Java 1.7 related to characters? Our application does a lot of processing of incoming files to then load them into a database and I want to ensure that when we upgrade to Java 1.7 that the reading of a file from java and the writing to the database of that content wont result in some odd character conversions.

升级到1.7时,我是否需要担心?如果是这样,我如何获得与Java 1.6相同的编码?

Do I need to be concerned at all when upgrading to 1.7? If so, how to I get the same encoding that we had in Java 1.6?

推荐答案

发生此错误是因为您已经告诉Java编译器您的源是UTF-8编码的,但是它仍然包含一些ISO-8859-1扩展字符.最近,我不得不在从1.5迁移到1.6的代码库中修复类似的错误.我相信Java 7在UTF-8编码方面比以前的版本要严格得多,并且会在以前不正确地接受不正确的编码的情况下发出错误消息.

The error occurs because you've told the Java compiler that your source is UTF-8 encoded, but it still contains some ISO-8859-1 extended characters. I recently had to fix similar errors in a codebase that was migrated from 1.5 to 1.6. I believe that Java 7 is much stricter about UTF-8 encoding than previous versions and will issue errors where previously the incorrect encodings were silently accepted.

您需要确保您的源代码是"Unicode-clean"的,也就是说,您必须将任何扩展的ISO-8859-1字符替换为它们的Unicode等价物.

You will need to make sure that your source code is "Unicode-clean", that is, you must replace any extended ISO-8859-1 characters with their Unicode equivalents.

这篇关于Java 1.7是否使用其他字符编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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