ascii code

I am getting a character with a "question mark inside a box". Does anybody know what ascii character i.e. what ascii number would it be. When I copy it in word I get it but when I copy it in notepad it only gives a box. I need to replace that inside my sed command in .SH file so I need to type it and since I cannot find its number anywhere I am unable to type it in notepad.

Thanks,

echo "yourdata" | od -ba
cat yourfile | od -ba

Or if you have older od, then option ex. -c or -x

Unix:
To see the unusual characters in a file in octal (the less unusual characters come out as \x. e.g. Tab is "\t").

sed -n l filename

Once you know the octal representation you can get the character into an environment variable with unix echo. My echo doesn't have the "-n" switch (no newline).

e.g. For the simple case of a tab character:

TAB=`echo "\0011\c"`

We can then use ${TAB} in a sed.

The common characters are listed in unix "man ascii". In your case the character is probably a higher value than those in "man ascii" but this "man" page is a good reference for converting between number bases (octal, decimal, hexadecimal).

Now for M$ Windows:
Once you have the octal value of the character you can convert to decimal (mathematics).

Say if you need to generate the unusual character in Windows Notepad:
Ensure that numlock is on.
Press and hold ALT then type the decimal version of the character on the numeric keyboard.
For example, the Euro Sign (�) is ALT+0128 .

in Word check the font type, then search in character map under the corresponding font for this character.

A couple of other higher-ascii tricks to add to the excellent suggestions above;

  • ls -b Converts unprintable (or weirdly printed) characters in filenames into octal
  • cat -vet Displays a file with all characters displayed (also useful for finding things like carriage returns added to the normal unix line feeds a-la Windows, or page breaks)