zsh-users
 help / color / mirror / code / Atom feed
From: Philippe Troin <phil@fifi.org>
To: "Johann 'Myrkraverk' Oskarsson" <johann@myrkraverk.com>
Cc: ZSH Users <zsh-users@sunsite.dk>
Subject: Re: Are there "binary" variables?
Date: 02 Jun 2006 19:41:42 -0700	[thread overview]
Message-ID: <87bqtbgduh.fsf@tantale.fifi.org> (raw)
In-Reply-To: <87lksfgdyq.fsf@tantale.fifi.org>

Philippe Troin <phil@fifi.org> writes:

> "Johann 'Myrkraverk' Oskarsson" <johann@myrkraverk.com> 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.


  reply	other threads:[~2006-06-03  2:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-03  0:21 Johann 'Myrkraverk' Oskarsson
2006-06-03  2:39 ` Philippe Troin
2006-06-03  2:41   ` Philippe Troin [this message]
2006-06-03  5:51 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqtbgduh.fsf@tantale.fifi.org \
    --to=phil@fifi.org \
    --cc=johann@myrkraverk.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).