ascii file read/printing in Linux
Hi All,
I am trying to read a bit file (in ASCII format) and printing the same on console. If i open the file i could see the following data: ">^H^D^L*^M^L^M^L<80>^L^X<8c>^@^@<80>p^H^B^@H08^B^@x^@^^^@<80>^@^@^@^@^@< 80>^@^@^@^@^@^@^@^@^@<88>^@^@^@^@^@<80>^B^@<80>^@^@^@^@^@^@<80>^@^H^@^@^ @^@^@<80>^@<80>^@^@^@^@^@^@^@^L^L<80>^@^@^D<80>^@^@^@^@^@^@^@<80>^@^@^@< 80>^@<80" but when i am trying to print using %c or %d i could not able to match the both. Is there any way to print the same ??? Please give me some suggestions on this. Thanks Srinivas :confused: |
> but when i am trying to print using %c or %d i could not able to match the both.
Sorry, but I don't quite get what you are trying to do! Are you just trying to display the while with a file reader or text editor, or are you trying to open and print it from within a C program you are coding? Anyway, it doesn't look as if it is a plain ASCII file you have there. Perhaps it is compressed some way? could you check with the 'file' utility what type of content is in the file? |
when i use file utility "data" is displayed.
MyFile.bit: data - Srinivas |
Just to add one more point here is, I am using Open() system call to open the file and then read() system call to read the file and then copying the data to a buffer and then printing the same (in C program).
Thanks Srinivas |
Oh dear... I thought it had something to do with C. Sorry, I am not a programmer.
But there is Programming forum here at the site, that would be a better place to post this! But here is what I think: It is not the reading that fails, but the output to your terminal emulator. A plain ASCII file would contain only alphanumeric characters, interpunctation, etc., but your file contains binary data. Terminal emulators tend to get confused by full 8bit output, since they interpret some bytes as control sequences. If you remember programming under DOS, you also got into trouble if you wanted to print out the first 32 ASCII characters, for the very same reason. |
May be this will help:
http://www.metalshell.com/view/source/27/ |
All times are GMT -5. The time now is 11:19 AM. |