Hello,
is there a simple way to convert a number to its ASCII representation.
eg : 65 => 'A'
Thanks in advance.
--
Use our news server 'news.foorum.com' from anywhere.
More details at: http://nnrpinfo.go.foorum.com/
Hello,
is there a simple way to convert a number to its ASCII representation.
eg : 65 => 'A'
Thanks in advance.
--
Use our news server 'news.foorum.com' from anywhere.
More details at: http://nnrpinfo.go.foorum.com/
$ awk 'BEGIN { printf("%c\n", 65); exit }'
A
> Hello,
> is there a simple way to convert a number to its ASCII representation.
> eg : 65 => 'A'
solaris has a chart of hex/oct to ascii in /usr/pub/ascii...
you could parse that. the man page has a decimal version, though
the actual file does not...hmmm....
--
robert sherman
css3, school of civil and environmental engineering
georgia institute of technology
atlanta, ga, usa
awk 'BEGIN { printf("%c\n", 65); }'Quote:> Hello,
> is there a simple way to convert a number to its ASCII representation.
> eg : 65 => 'A'
regards,
Ben
d2c() { ## USAGE: d2c NNN - NNN = decimal numberQuote:> Hello,
> is there a simple way to convert a number to its ASCII representation.
> eg : 65 => 'A'
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2002, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
> > Hello,
> > is there a simple way to convert a number to its ASCII representation.
> > eg : 65 => 'A'
> d2c() { ## USAGE: d2c NNN - NNN = decimal number
> eval echo `printf "\$'\\\x%x'\n" $1`
> }
d2c() {
eval echo `printf "\$'\\\\\x%x'\n" $1`
}
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2002, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
> > > Hello,
> > > is there a simple way to convert a number to its ASCII representation.
> > > eg : 65 => 'A'
> > d2c() { ## USAGE: d2c NNN - NNN = decimal number
> > eval echo `printf "\$'\\\x%x'\n" $1`
> > }
> Slashed when trying to escape!
> d2c() {
> eval echo `printf "\$'\\\\\x%x'\n" $1`
> }
> > > > Hello,
> > > > is there a simple way to convert a number to its ASCII representation.
> > > > eg : 65 => 'A'
> > > d2c() { ## USAGE: d2c NNN - NNN = decimal number
> > > eval echo `printf "\$'\\\x%x'\n" $1`
> > > }
> > Slashed when trying to escape!
> > d2c() {
> > eval echo `printf "\$'\\\\\x%x'\n" $1`
> > }
> It worked the original way on bash.
$ d2c 77
bash: printf: missing hex digit for \x
M
The whole thing only works, apparently, on bash and ksh93.
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2002, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
--
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> Smaller than perl or awk:
> echo 65P | dc
perl -e 'print chr(65), "\n"'
presented by someone else, can be reduced to
perl -le 'print chr 65'
Peter
--
People say I'm indifferent, but I don't care.
Thanks to all,
The solution with 'echo' doesn't work for me.
And, as I use a variable for 65, 66, etc, I use awk which works perfectly.
Thanks again.
--
Use our news server 'news.foorum.com' from anywhere.
More details at: http://nnrpinfo.go.foorum.com/
>Smaller than perl or awk:
>echo 65P | dc
This doesn't work in all versions of 'dc', values 1-99
seem to always work but above that it's implementation
dependant and systems I've seen that fail (IIRC: HP-UX, SunOS)
output the string that is the base-100 expansion of the
value (eg; 100-> 0,1 outputs nothing 165-> 65,1 outputs A,\01 )
It's safer to use 'tr';
echo z|tr 'z' \\`echo 8o65p|dc`
>--
>GEMINI: Your birthday party will be ruined once again by your explosive
>flatulence. Your love life will run into trouble when your fiancee hurls a
>javelin through your chest. -- Weird Al, _Your Horoscope for Today_
--
# http://lf.8k.com http://lf.1accesshost.com
"Perfection is achieved, not when there is nothing more to add,
but when there is nothing left to take away" (Antoine de Saint-Exupery)
1. Need sed script to convert Mac ascii to Unix ascii
We have consultants delivering jsp files in Mac ascii format. We need
them in Unix ascii format. Does anyone have a mac to Unix utility or
can someone tell me how to do it using sed?
Thanks
BTW, Mac ascii files have lines ending in the character CR or 0D.
Unix of course is CRLF or ODOA.
Thanks
3. Converting Mac ascii to Unix ascii?
5. Converting Mac ASCII files to UNIX
7. Converting an ASCII file to a Binary File
8. For Two NIC -> Two Entries in /etc/hosts
9. Can tex files be converted to ASCII files
10. Convert aix ascii file to dos
11. Print files with formatting codes, convert to ASCII?
12. how to convert paper.ascii.gz to plain text?
13. Is there a utility to convert an ASCII string in a binary file?