On 2018-06-07, at 20:05:25, Paul Gilmartin wrote:
>
> Here's my test code page generator:
>
Oops. Trying again:
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
# Doc: Convert various IBM code pages to UTF-8
# Run this in an empty, taggable z/OS UNIX directory.
( set -x; cp -ip "$0" . ) # Save a copy for export.
toUTF_8() { iconv -f "$CP" -t UTF-8; }
# Generate either argument code page or standard list.
Sets="${1:-ISO8859-1 ISO8859-5 IBM-500 IBM-037 \
IBM-277 IBM-870 IBM-880 IBM-1154 IBM-1047}"
case "$( printf '\141' )" in
'a') HostCP=ISO8859-1;; # (Sorta ASCII. )
'/') HostCP=IBM-1047;; esac # (Sorta EBCDIC.)
export HostCP
for CP in $Sets; do
TestC="$( printf '\n\132' | iconv -f "$CP" -t "$HostCP" )" ||
continue # CP not found; iterate Sets
F="from_$CP"
case "$TestC" in
*Z )
ASCII=1
CS=ASCII;;
* )
ASCII=0
CS=EBCDIC;; esac
ASCII="$ASCII" \
CP="$CP" \
F="$F" \
LC_ALL=en_US \
awk '
function Encode( A ) {
system( "set +x; printf %s \""A"\" |" \
"iconv -f \"$HostCP\" -t "CP" 2>/dev/null" ) }
BEGIN {
ASCII = ENVIRON[ "ASCII" ] + 0
SP = 32 * ( 2 - ASCII )
CP = ENVIRON[ "CP" ]
Encode( " Host: "ENVIRON[ "HostCP" ] \
" output: "ENVIRON[ "F" ]"\n " )
for ( K = 0; K<256; K+=16 )
Encode( sprintf( "%4d", K ) ) # Top label
Encode( sprintf( "\n " ) )
for ( K = 0; K<256; K+=16 )
Encode( sprintf( "%4x", K ) ) # Top label
Encode( sprintf( "\n" ) )
for ( J = 0; J<16; J++ ) {
Encode( sprintf("\n%4d %2x", J, J ) ) # Left label
for ( KK = 0; KK<256; KK+=16 ) {
K = J + KK
if ( ASCII )
{ if ( K<32 || K>=127 && K<160 ) K = SP }
else if ( K<64 || K==255 ) K = SP
printf( "%c%c%c%c", SP, SP, SP, K ) }
}
Encode( sprintf( "\n" ) )
}' | # End of awk
tee "raw_$CS" | # Save as raw SBCS
toUTF_8 | tee "$F" | # Save as UTF-8
iconv -f ISO8859-1 -t "$HostCP" # Translate to IBM-1047 so ssh
translates to ASCII.
case "$HostCP" in
ISO8859-1) ls -l "$F";;
*) chtag -tcUTF-8 "$F"
extattr -F LF "$F"
ls -lTHE "$F";; esac
done
chtag -tcISO8859-1 "raw_ASCII"
extattr -F LF "raw_ASCII"
chtag -tcIBM-1047 "raw_EBCDIC"
extattr -F NL "raw_EBCDIC"
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
I hate EBCDIC!
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN