12e5b6d6dSopenharmony_ci#!/usr/bin/qsh 22e5b6d6dSopenharmony_ci# Copyright (C) 2016 and later: Unicode, Inc. and others. 32e5b6d6dSopenharmony_ci# License & terms of use: http://www.unicode.org/copyright.html 42e5b6d6dSopenharmony_ci# Copyright (C) 2000-2011, International Business Machines 52e5b6d6dSopenharmony_ci# Corporation and others. All Rights Reserved. 62e5b6d6dSopenharmony_ci# 72e5b6d6dSopenharmony_ci# Authors: 82e5b6d6dSopenharmony_ci# Ami Fixler 92e5b6d6dSopenharmony_ci# Barry Novinger 102e5b6d6dSopenharmony_ci# Steven R. Loomis 112e5b6d6dSopenharmony_ci# George Rhoten 122e5b6d6dSopenharmony_ci# Jason Spieth 132e5b6d6dSopenharmony_ci# 142e5b6d6dSopenharmony_ci# 152e5b6d6dSopenharmony_ci# This script detects if any UTF-8 files were incorrectly converted to EBCDIC, and 162e5b6d6dSopenharmony_ci# converts them back. 172e5b6d6dSopenharmony_ci 182e5b6d6dSopenharmony_ciif [ -z "$QSH_VERSION" ]; 192e5b6d6dSopenharmony_cithen 202e5b6d6dSopenharmony_ci QSH=0 212e5b6d6dSopenharmony_ci echo "QSH not detected (QSH_VERSION not set) - just testing." 222e5b6d6dSopenharmony_cielse 232e5b6d6dSopenharmony_ci QSH=1 242e5b6d6dSopenharmony_ci #echo "QSH version $QSH_VERSION" 252e5b6d6dSopenharmony_cifi 262e5b6d6dSopenharmony_ciexport QSH 272e5b6d6dSopenharmony_ci 282e5b6d6dSopenharmony_citar_file=$1 292e5b6d6dSopenharmony_ciecho "" 302e5b6d6dSopenharmony_ciecho "Determining binary files by BOM ..." 312e5b6d6dSopenharmony_ciecho "" 322e5b6d6dSopenharmony_cibin_count=0 332e5b6d6dSopenharmony_cibinary_files="" 342e5b6d6dSopenharmony_ci# Process BOMs 352e5b6d6dSopenharmony_ci for file in `find ./icu/source/data/unidata \( -name \*.txt -print \)`; do 362e5b6d6dSopenharmony_ci bom8=`od -t x1 -N 3 $file|\ 372e5b6d6dSopenharmony_ci head -n 1|\ 382e5b6d6dSopenharmony_ci cut -c10-18`; 392e5b6d6dSopenharmony_ci #Find a converted UTF-8 BOM 402e5b6d6dSopenharmony_ci echo "file $file bom /${bom8}/" 412e5b6d6dSopenharmony_ci if [ "$bom8" = "57 8b ab" ] 422e5b6d6dSopenharmony_ci then 432e5b6d6dSopenharmony_ci file="`echo $file | cut -d / -f2-`" 442e5b6d6dSopenharmony_ci echo "converting ${file}" 452e5b6d6dSopenharmony_ci if [ `echo $binary_files | wc -w` -lt 200 ] 462e5b6d6dSopenharmony_ci then 472e5b6d6dSopenharmony_ci bin_count=`expr $bin_count + 1` 482e5b6d6dSopenharmony_ci binary_files="$binary_files $file"; 492e5b6d6dSopenharmony_ci else 502e5b6d6dSopenharmony_ci echo "Restoring binary files by BOM ($bin_count)..." 512e5b6d6dSopenharmony_ci rm $binary_files; 522e5b6d6dSopenharmony_ci pax -C 819 -rvf $tar_file $binary_files; 532e5b6d6dSopenharmony_ci echo "Determining binary files by BOM ($bin_count)..." 542e5b6d6dSopenharmony_ci binary_files="$file"; 552e5b6d6dSopenharmony_ci bin_count=`expr $bin_count + 1` 562e5b6d6dSopenharmony_ci fi 572e5b6d6dSopenharmony_ci fi 582e5b6d6dSopenharmony_ci done 592e5b6d6dSopenharmony_ci if [ `echo $binary_files | wc -w` -gt 0 ] 602e5b6d6dSopenharmony_ci then 612e5b6d6dSopenharmony_ci echo restoring 622e5b6d6dSopenharmony_ci rm $binary_files 632e5b6d6dSopenharmony_ci pax -C 819 -rvf $tar_file $binary_files 642e5b6d6dSopenharmony_ci fi 652e5b6d6dSopenharmony_ci 662e5b6d6dSopenharmony_ci 672e5b6d6dSopenharmony_ci 68