summaryrefslogtreecommitdiff
path: root/intl/icu/as_is/os400/fixup-icu.sh
blob: 092c748a5113523cd89091e9d06743f2bd2b939f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/qsh
#   Copyright (C) 2000-2011, International Business Machines
#   Corporation and others.  All Rights Reserved.
#
# Authors:
# Ami Fixler
# Barry Novinger
# Steven R. Loomis
# George Rhoten
# Jason Spieth
#
#
# This script detects if any UTF-8 files were incorrectly converted to EBCDIC, and 
# converts them back.

if [ -z "$QSH_VERSION" ];
then
	QSH=0
    echo "QSH not detected (QSH_VERSION not set) - just testing."
else
	QSH=1
	#echo "QSH version $QSH_VERSION"
fi
export QSH

tar_file=$1
echo ""
echo "Determining binary files by BOM ..."
echo ""
bin_count=0
binary_files=""
# Process BOMs
   for file in `find ./icu/source/data/unidata \( -name \*.txt -print \)`; do
    bom8=`od -t x1 -N 3 $file|\
          head -n 1|\
          cut -c10-18`;
    #Find a converted UTF-8 BOM
    echo "file $file bom /${bom8}/"
    if [ "$bom8" = "57 8b ab" ]
    then
        file="`echo $file | cut -d / -f2-`"
        echo "converting ${file}"
        if [ `echo $binary_files | wc -w` -lt 200 ]
        then
            bin_count=`expr $bin_count + 1`
            binary_files="$binary_files $file";
        else
            echo "Restoring binary files by BOM ($bin_count)..."
            rm $binary_files;
            pax -C 819 -rvf $tar_file $binary_files;
            echo "Determining binary files by BOM ($bin_count)..."
            binary_files="$file";
            bin_count=`expr $bin_count + 1`
        fi
    fi
  done
    if [ `echo $binary_files | wc -w` -gt 0 ]
      then
        echo restoring
        rm $binary_files
               pax -C 819 -rvf $tar_file $binary_files
       fi