Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java 1.7 use a different character encoding?

Tags:

java

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 Ó).

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.

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?

like image 819
BestPractices Avatar asked Nov 15 '12 20:11

BestPractices


1 Answers

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.

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.

like image 151
Jim Garrison Avatar answered Oct 16 '22 15:10

Jim Garrison