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