[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dhcp-server
Subject:    Re: binary-to-ascii
From:       Glenn Satchell <Glenn.Satchell () uniq ! com ! au>
Date:       2003-06-29 14:07:44
[Download RAW message or body]

   *** From dhcp-server -- To unsubscribe, see the end of this message. ***


> From: Martin Jackson <mhjacks@swbell.net>
> 
> Keith Neufeld wrote:
> > 
> >>binary-to-ascii(16,8,"", substring(hardware, 1, 6))
> >>
> >>Does almost the same thing:
> >>
> >>040abcdef
> >>
> >>What I'm looking for is
> >>
> >>004000abcdef
> > 
> > 
> > Okay, I see your point about leading-zero suppression.

This is pretty ugly, but doesn't require any changes to the source code:

concat (
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 1, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 2, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 3, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 4, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 5, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 6, 1))),2)
);

Basically gets each char, sticks a 0 on the front, then takes the last
two chars, then concatenates the whole thing.

regards,
-glenn


-----------------------------------------------------------------------
List Archives : http://www.isc.org/ml-archives/dhcp-server/
Unsubscribe   : http://www.isc.org/dhcp-lists.html    
-or-          : mailto:dhcp-server-request@isc.org?Subject=unsubscribe  
-----------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic