Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Are there "binary" variables?



Philippe Troin <phil@xxxxxxxx> writes:

> "Johann 'Myrkraverk' Oskarsson" <johann@xxxxxxxxxxxxxx> writes:
> 
> > Is there a way to work with binary data in zsh?  That is, more
> > specifically, is there a way to compare ^E to 5 and get true?  Or
> > convert a character (say, ^E again) to its integer representation?
> 
> Zsh's parameters are 8-bits clean.
> 
> You could do the above with:
> 
> typeset -A asc
> for i in {0..255}; do asc[$(print "\\$(([##8]$i))")]=$i;done
> var=$'\0\1\2\3'
> for i in $#var; do print "$i: $asc[$var[$i]]"; done

Actually, the last line should read:

for i in {1..$#var}; do print "$i: $asc[$var[$i]]"; done

Phil.



Messages sorted by: Reverse Date, Date, Thread, Author