How to convert xml file which is in non UTF-8 format to xml that is UTF-8 compliant How to convert xml file which is in non UTF-8 format to xml that is UTF-8 compliant shell shell

How to convert xml file which is in non UTF-8 format to xml that is UTF-8 compliant


Use the character set conversion tool:

iconv -f ISO-8859-1 -t UTF-8 filename.txt

See gnu-page

...and in file http://standards.ieee.org/develop/regauth/oui/oui.txt "aglia" (as in your example above) is reported as:

00-0B-91   (hex)            Aglaia Gesellschaft für Bildverarbeitung und Kommunikation m000B91     (base 16)        Aglaia Gesellschaft für Bildverarbeitung und Kommunikation m                            Tiniusstr. 12-15                            Berlin  D-13089                            GERMANY

it seems like "ü" is the character that gets mangeld.

Update

When downloading "oui.txt" using wget, I see the character "ü" in the file. If you don't have that something is broken in your download. consider using one of these:

  • wget --header='Accept-Charset: utf-8'
  • try using curl -o oui.txt instead

If none of the above works, just open the link in you favorite browser and do a "save as". In that case, comment the wget line in the script below.

I had success with the following script (update BEGIN & END to get a valid XML-file)

#!/bin/bashwget http://standards.ieee.org/develop/regauth/oui/oui.txticonv -f iso-8859-15 -t utf-8 oui.txt > convertedawk 'BEGIN {         print "HTML-header"     }     /base 16/ {         printf("<vendor name=\"%s\">\n", $4)         read         desc = substr($0, index($0, $4))         printf("<vendorOUI oui=\"%s\" description=\"%s\"/>\n", $1, desc)     }     END {         print "HTML-footer"    }    ' converted

Hope this helps!