0
I have a project (in java) with more than 100 files, some of them are in ISO others in UTF8.
How to change the encoding of all ISO files to UTF-8 without losing the special characters ?
0
I have a project (in java) with more than 100 files, some of them are in ISO others in UTF8.
How to change the encoding of all ISO files to UTF-8 without losing the special characters ?
3
If you are using the Eclipse:
If you’re in the Netbeans:
As you said your project has more than 100 files in different encoding than UTF-8, and you will change them, it is very likely that a lot of special characters will break (even if you don’t want to). For example: "á" can flip " ". What’s more, if you compile your software, you may have an error of unmappable Character.
Take a test in Netbeans, I did some tests here and didn’t break the special characters, unlike Eclipse.
1
It is good to configure your editor to use the correct encoding later, but initially it is much better to convert the files automatically.
If you’re on a Unix, just use recode:
$ recode utf8 *.java
To process recursively:
$ find . -name "*.java" -exec recode utf8 {} \;
The recode is quite flexible, you can do a lot more things. Credits to this reply.
Browser other questions tagged utf-8 character-encoding iso-8859-1
You are not signed in. Login or sign up in order to post.
UTF-8 includes all ISO-8859-1 characters, so any well-made converter should be able to convert all files without error characters.
– luiscubal
I did three tests here converting "áãâéêííóú". Notepad++, Eclipse and Netbeans. All tests converting from ISO-8859-1 to UTF-8. Result: Break in Notepad++ and Eclipse. In Netbeans, conversion did not break special characters.
– humungs
If the conversion is well done, it won’t break. I did the Notepad++ experiment and it works. (explicitly choose "Convert to UTF-8", not "Encode in UTF-8")
– luiscubal
Correct @luiscubal. I just changed the encoding.
– humungs