Re: Any clever ways to convert octet strings to ASCII?

Cameron Laird (claird@Starbase.NeoSoft.COM)
Fri, 11 Apr 1997 02:34:19 -0500 (CDT)

From owner-tkined@ibr.cs.tu-bs.de Thu Apr 10 14:05:08 1997
.
.
.
I'm using Scotty and doing gets and getnexts just fine, but I'd
like to convert the octet strings from their hex format into
regular ASCII before displaying them. Before I write a routine
to do so (given that my style of coding is "college dormitory furniture" -
ugly, kludgy, and semi-functional), I thought I'd ask to see if anyone
has come up with a good way of doing this. Thanks much.
.
.
.
Yes.

There's actually more to this story, mostly having to
do with
1. whether you should be setting up MIBs so Scotty
will do the display code for you, and the
hazards of *not* proceding in this way,
2. where to look for things inside Scotty's existing
source, and
3. proposals Juergen has considered for clever and
far more general-purpose approaches to data con-
version in an SNMP context.

For today, I'll give you the short answer:

########
#
# hex_to_display
#
# Cameron Laird. 11 April 1997.
#
# Typical operation: "hex_to_display 5A:43:6c:71"
# yields "ZClq".
#
########
proc hex_to_display hex_representation {
# The point of the sysDescr is that RFC
# 1907 defines it as of DisplayFormat.
# Any other DisplayFormat would do
# equally well.
# There's a natrual inverse to this, with
# "mib scan ..." at its core.
return [mib format sysDescr $hex_representation]
}

Cameron Laird http://starbase.neosoft.com/~bodi/nesi.html
Network Engineered Solutions +1 713 763 8366
claird@NeoSoft.com +1 281 996 8546 FAX
Houston WWW Business Guide: http://starbase.neosoft.com/~bodi/HouGuide.html

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.