So I have been spending the last two days trying every possible solution on all the other entries but have had no result so far. Our company developed a software that converts .XML files into .TXT while also filtering the fields that we need.
Recently we have received over 500 files from a client and have neither been able to run the program, nor opening it in a browser correctly. A few ways to overcome the problem are either removing manually the special characters such as ã
, ç
, è
, ô
or changing the encoding from UTF-8 to ISO-8859-1.
Sensing that it would be easier to create a command to change the encoding from all the files I got to the following command:
iconv -c -f UTF-8 -t ISO-8859-1 test.xml > test1.xml
By using this command I am able to open it in a browser and convert it correctly into .TXT by using our own program. My challenge is to apply this command to all of the 500 files. I have tried these suggestions, without result:
for %a in (*.xml) do iconv -c -f UTF-8 -t ISO-8859-1 %a
and
find . -name ".xml" -exec iconv -c -f UTF-8 -t ISO-8859-1
And several other variations of these two, but I had no results so far... Any idea or advice is welcome. Thank you in advance!
UPDATE:
I decided to give it a try with recode using:
recode UTF-8..ISO-8859-1 *.xml
but it returns:
failed: Invalid input in step 'UTF-8..ISO-8859-1'
UPDATE 2:
I have found a solution, by forcing the recode function. This is what the command looked like:
recode -f UTF-8..ISO-8859-1 *xml
I must say that all the special characters such as ã,ç,ê where lost in the process, but since I only need access to the numbers this solution works fine for me. Im sure there is a cleaner way to doing it without loosing information, but this worked for me...