Introspection fixes
[gnumeric.git] / tools / fixup-old-files
blobd09cab0e120ab246ef3939b102e676d10de86558
1 #!/bin/bash
3 # This is a script that will update files from 1.0.x versions if you
4 # get errors like...
5 # Input is not proper UTF-8, indicate encoding !
6 # Bytes: 0xE9 0x73 0x20 0x70
7 # We aren't sure why these happen for some people, but given the age
8 # of the 1.0.x series we probably won't spend more time on the issue.
10 # It assumes that the files were using ISO8859-1 encoding. (Files
11 # from Gnumeric before 1.2 do not contain encoding information. That's
12 # the whole problem, in fact.)
14 # Adapted from script by daniel.savard@gmail.com
16 # Almost completely untested, btw.
17 # PLEASE BACKUP YOUR FILES FIRST!
19 my_file=$1
20 tmp=/tmp/conv_$$.gnumeric
22 if [ -f $tmp ]; then
23 rm -f $tmp
26 type=`file "$my_file" | sed -e 's/^.*:[ ]*//' -e 's/[ ].*//'`
27 if [ "$type" != "gzip" ]
28 then
29 echo "$my_file"
30 echo "Incompatible file format."
31 exit 1
34 if [ -w "$my_file" ]; then
35 gzip -d < "$my_file" | iconv -f ISO8859-1 -t UTF-8 | sed s/'<?xml version="1.0"?>'/'<?xml version="1.0" encoding="UTF-8"?>'/ | gzip > $tmp
36 mv $tmp "$my_file"
39 exit 0