From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19450 invoked from network); 3 Jun 2006 02:42:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.2 (2006-05-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.2 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Jun 2006 02:42:03 -0000 Received: (qmail 83146 invoked from network); 3 Jun 2006 02:41:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Jun 2006 02:41:57 -0000 Received: (qmail 14989 invoked by alias); 3 Jun 2006 02:41:48 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10349 Received: (qmail 14979 invoked from network); 3 Jun 2006 02:41:47 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 3 Jun 2006 02:41:47 -0000 Received: (qmail 81602 invoked from network); 3 Jun 2006 02:41:47 -0000 Received: from tantale.fifi.org (64.81.251.130) by a.mx.sunsite.dk with SMTP; 3 Jun 2006 02:41:46 -0000 Received: (from phil@localhost) by tantale.fifi.org (8.9.3p2/8.9.3/Debian 8.9.3-21) id TAA08428; Fri, 2 Jun 2006 19:41:42 -0700 Sender: phil@fifi.org To: "Johann 'Myrkraverk' Oskarsson" Cc: ZSH Users Subject: Re: Are there "binary" variables? References: <87lksfgdyq.fsf@tantale.fifi.org> Mail-Copies-To: nobody From: Philippe Troin Date: 02 Jun 2006 19:41:42 -0700 In-Reply-To: <87lksfgdyq.fsf@tantale.fifi.org> Message-ID: <87bqtbgduh.fsf@tantale.fifi.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Philippe Troin writes: > "Johann 'Myrkraverk' Oskarsson" 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.