I have a file with properties in French.
I would like to convert it to ISO8859-1.
But after conversion, some symbols are lost.
What is wrong?

> cat fr.properties
VAR2="élément n’a"
> cat fr.properties | iconv -f UTF-8 -t ISO8859-1 | iconv -f ISO8859-1 -t UTF-8
VAR2="élément na"

Is that character present in the ISO8859-1 encoding? I don't believe it is. Which makes this expected behavior.

To be clear: iconv's output in the iconv -f UTF-8 -t ISO8859-1 must be completely in the ISO8859-1 encoding. It can't leave ANYTHING in UTF-8. So, if there's a character in the input text that can't be represented in ISO8859-1, then iconv drops it.

When you then convert back, there's no way for the iconv -f ISO8859-1 -t UTF-8 command to ever know that the missing character existed, so you don't get it on the other end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.