ascii code

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ascii code
# 1  
Old 08-10-2009
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.

# 2  
Old 08-10-2009
echo "yourdata" | od -ba
cat yourfile | od -ba

Or if you have older od, then option ex. -c or -x
# 3  
Old 08-10-2009
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 .

Last edited by methyl; 08-10-2009 at 07:03 PM.. Reason: Various typos and missing tags
# 4  
Old 08-10-2009
in Word check the font type, then search in character map under the corresponding font for this character.
# 5  
Old 08-10-2009
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)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Creating data delimited by ASCII code 1

<Any suggestion how to create a file where the values are separated by ASCII code 1,with data extracted from a table using shell script The format is :/> <columnname1(binary1)columnvalue(binary1)columnname2(binary1)columnvalue(binary1)columnname3(binary1)columnvalue... 1st row/>... (6 Replies)
Discussion started by: dasun
6 Replies

2. Shell Programming and Scripting

Convert Hex to Ascii in a Ascii file

Hi All, I have an ascii file in which few columns are having hex values which i need to convert into ascii. Kindly suggest me what command can be used in unix shell scripting? Thanks in Advance (2 Replies)
Discussion started by: HemaV
2 Replies

3. Shell Programming and Scripting

Bash - binary data to ascii code

Hello, With bash-script (ubunto server) I'm trying to read a binary file and, for each character, give back its ascii code (including extended ascii). For example: HEX => ASCII => PRINT f5 => 245 => 50 => 80 => P To load the binary file into a variable I tried in this way: ... (2 Replies)
Discussion started by: math4
2 Replies

4. Shell Programming and Scripting

sort -t option causing code to fail need ASCII character

Hello, When I run this UNIX code without the -t option it gives me the desired results. The code keeps the record with the greatest datetime based on the key columns. I sort it first then sort it again with the -u option, that's it. I need to have a variable to specify an ASCII character... (2 Replies)
Discussion started by: script_op2a
2 Replies

5. UNIX for Advanced & Expert Users

Conversion from ASCII to binary for physical simulation code in C/C++

Good evening, everybody A good math friend told me that it would be possible to shrink the size of the numerical datas I produce with a physical simulation code I programmed for my PhD. It usually writes at least 100 GB to complete the simulation, and it seems that it is too high. There are... (7 Replies)
Discussion started by: Cybertib
7 Replies

6. Shell Programming and Scripting

convert ascii values into ascii characters

Hi gurus, I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
Discussion started by: sandeeppvk
10 Replies

7. Shell Programming and Scripting

code ASCII for Caracter -->> '

I'm a question: the expresiion 'expr $a +1' use the caracter --> ' (is not shift+ ? !!!) what is the code ascii for generate this caracter ?????? tank's (3 Replies)
Discussion started by: ZINGARO
3 Replies

8. Linux

source code ASCII to HEx

Is there are any source code in ANSI C to convert ASCII to Hexa decimal. (1 Reply)
Discussion started by: Thippeswamy
1 Replies

9. UNIX for Dummies Questions & Answers


a silly question but is there a way to display individual ascii values say if i type 65 it will display the letter instead? thanks fo any help. (3 Replies)
Discussion started by: melkor
3 Replies

10. UNIX for Dummies Questions & Answers

ascii for EOF ???

Could someone please post the ascii code for End Of File Thanks. (3 Replies)
Discussion started by: strpeski
3 Replies
Login or Register to Ask a Question