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