-2

I have a file composed of one line full of 8-bit binary number, i.e. like this:

01010100 01101000 01101001 01110011 00100000 01101001 01110011 00100000 01101010 01110101 01110011 01110100 00100000 01110100 01101000 01100101 00100000 01100010 01100101 01100111 01101001 01101110

I know for a fact that they are supposed to correspond to a ASCII symbol. For example 01010100correspond to the letter T ("capital t").

I'd like to convert it all to a txt file (there are in the list some \n and I've got a feeling that somehow ASCII-art will appear doing such. Can ou point me some shell method? I'd like to achieve that through the shell. Or at the very least Python.

ggrelet
  • 1,071
  • 7
  • 22
  • All the numbers you show evaluate to a number in the range 0..127 (0x00..0x7F) and therefore fall within the range of ASCII characters. What's the problem? Is the content of the file actually a series of 1 and 0 characters with a space after every group of 8 digits that must be transformed? (I'll observe it is a very wasteful way of storing or transferring data, using 72 bits for each 8-bit (7-bit?) value.) – Jonathan Leffler Nov 09 '17 at 21:05
  • A very simple C program can do the job pretty easily, reading from standard input and writing to standard output. For example: `#include #include int main(void) { char number[9]; while (scanf("%8s", number) == 1) putchar(strtol(number, 0, 2)); return 0; }`. When run on the data you show, it yields: `This is just the begin`. Clearly, there's barely any error checking and only minimal error prevention; you get what you get if the data is mal-formatted after all. But the job is not very complex. (The C code needs to be on at least 3 lines.) – Jonathan Leffler Nov 09 '17 at 22:10

1 Answers1

0

Well, you could get a hold of a acsii binary conversion table and read it into an associative array. e.g. ascii["110000"]=0 etc. and then just plow through the file