Custom Binary Format
I found a chart for translating ASCII into Binary and other codes at:
I know you can save text as binary, but I was wondering, is there a way to make a program that
will save text as binary but in a different binary format?
For an example,
A = 01000001
B = 01000010
But instead of that I would have it like this.
A = 00000001
B = 00000010
As you see that would make it so that you have to have a program specially designed to read it,
not just any word processor would do. So it would be a custom format. Can this be done? And if
(P.S. I would want program only to be able to read A-Z and 0-9 only.)
There are numerous ways to approach this problem. A very simple method that comes to mind is to make a 256 element array of integers. Each element in this array would correspond to an ascii value. For instance, array element 'a' would be 97 decimal or 0x61. Then stored at that location you would put the value you would like to use to represent this in your program. So you might decide this would be 0000 0011 binary or 3 in decimal. Likewise you could have another array to convert the other direction.
Simply encode the data and then write to disk. Do the reverse during input. Enhance the process via multithreading.
I may be missing the point but can you just subtract 64 from the ASCII value before you encode to binary.
That could be done, yes. If that's the only encoding you are wanting to do, it would work fine. Then in reading the file you would add 64 to the value again.
Yes. Tell me how you can add or subtract 64 from the binary code.
Well, when saving a file, one approach would be to put the entire contents of the file to be into an allocated character array and then loop through each element, subtracting 64 from each value. The same applies for reading in. Store the entire file contents into an allocated character array and then loop through, adding 64 to each element.
I think I understand what you are saying but I don't know how to do all of those things, could you give me an example to work with?
if you want 'a' to be 0 and 'b' to be 1 then you would subtract 65
Since the value of Z is 90 and the value of a is 97 you might want to check the range of the char values before modifying them but that depends on how you want things encoded.
for (int i=0;Array[i]!=0;i++)
I still don't get it :(
I'm only a newbie
Well, if you're that much of a newbie, I really suggest you do more work with base C or C++ programming. Win32 API is just a bunch of predefined C and C++ functions, data types, structures, ect. and if you don't know hoe they work, you're gonna have a pretty hard time learning it. Spend at least a few weeks working with C or C++ (I prefer C, but most prefer C++) and then see how API goes for you.
Guess you'r right, thanks anyway though.