1#!/usr/bin/qsh 2# Copyright (C) 2000-2011, International Business Machines 3# Corporation and others. All Rights Reserved. 4# 5# Authors: 6# Ami Fixler 7# Barry Novinger 8# Steven R. Loomis 9# George Rhoten 10# Jason Spieth 11# 12# 13# This script detects if any UTF-8 files were incorrectly converted to EBCDIC, and 14# converts them back. 15 16if [ -z "$QSH_VERSION" ]; 17then 18 QSH=0 19 echo "QSH not detected (QSH_VERSION not set) - just testing." 20else 21 QSH=1 22 #echo "QSH version $QSH_VERSION" 23fi 24export QSH 25 26tar_file=$1 27echo "" 28echo "Determining binary files by BOM ..." 29echo "" 30bin_count=0 31binary_files="" 32# Process BOMs 33 for file in `find ./icu/source/data/unidata \( -name \*.txt -print \)`; do 34 bom8=`od -t x1 -N 3 $file|\ 35 head -n 1|\ 36 cut -c10-18`; 37 #Find a converted UTF-8 BOM 38 echo "file $file bom /${bom8}/" 39 if [ "$bom8" = "57 8b ab" ] 40 then 41 file="`echo $file | cut -d / -f2-`" 42 echo "converting ${file}" 43 if [ `echo $binary_files | wc -w` -lt 200 ] 44 then 45 bin_count=`expr $bin_count + 1` 46 binary_files="$binary_files $file"; 47 else 48 echo "Restoring binary files by BOM ($bin_count)..." 49 rm $binary_files; 50 pax -C 819 -rvf $tar_file $binary_files; 51 echo "Determining binary files by BOM ($bin_count)..." 52 binary_files="$file"; 53 bin_count=`expr $bin_count + 1` 54 fi 55 fi 56 done 57 if [ `echo $binary_files | wc -w` -gt 0 ] 58 then 59 echo restoring 60 rm $binary_files 61 pax -C 819 -rvf $tar_file $binary_files 62 fi 63 64 65 66