Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Are there "binary" variables?
- X-seq: zsh-users 10349
- From: Philippe Troin <phil@xxxxxxxx>
- To: "Johann 'Myrkraverk' Oskarsson" <johann@xxxxxxxxxxxxxx>
- Subject: Re: Are there "binary" variables?
- Date: 02 Jun 2006 19:41:42 -0700
- Cc: ZSH Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <87lksfgdyq.fsf@xxxxxxxxxxxxxxxx>
- Mail-copies-to: nobody
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <m3irnjccn4.fsf@xxxxxxxxxxxxxxxxxx> <87lksfgdyq.fsf@xxxxxxxxxxxxxxxx>
- Sender: phil@xxxxxxxx
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