Technical article 127150

How can I echo a Hexadecimal or Octal value to the screen using the echo command?

OpenServer 6.0.0OpenServer 5.0.7UnixWare 7.1.4

Written · Last revised

Problem

I want to debug come character mapping issues on the console and I would like to be able to echo a character the screen using its hexadecimal or octal value. Is there a way I can do this?

Solution

You can your shell's echo directive to echo character glyphs to your terminal device using their hexadecimal and octal codes as follows:

To echo a hexadecimal code, from a bash shell prompt type:

echo "\x3A"

where 3A is replaced by the hexadecimal code you want to display.

The standard shell, /bin/sh, does not support echoing hexadecimal codes. It does however support octal codes.

To echo an octal code, from the shell prompt type:

echo "\0161"

where 161 is replaced by the octal code you want to display.

The SCO Console may be setup to use one of the following codesets:

ISO8859-1
CP437
CP850

For more information these codesets including the hexadecimal codes to use and they related glyphs please see:

http://en.wikipedia.org/wiki/ISO/IEC_8859-1
http://en.wikipedia.org/wiki/CP437
and
http://en.wikipedia.org/wiki/Cp850

From the Xinuos technical article database, record 127150. Reproduced with permission. The original is at www.sco.com/ta/127150, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.