|
-
Illuminatus!
Binary to text
I used to know this a year ago, but know its totally out of my head and bugging me.
How do I convert text to binary? Do I have to convert it to ascii first, and if I do, I remember there was a shortcut for text to ascii conversion, but thats all gone now, flushed out of my brain with alcohol.
I need your brains...
-
poet and narcisist
-
Always Twirling Toward Freedom
This is the one I always used to use
http://nickciske.com/tools/binary.php
-
poet and narcisist
mine is in flash...buuuuuuuuuuuuuh to you
-
Illuminatus!
Right, there's many convertors out there, I was looking for a manual way. Im looking through your source right now argo in the strtobit function, but frankly not understanding it. Sorry, I guess I turned into a thick designer...
-
poet and narcisist
Originally posted by fospher.com
Right, there's many convertors out there, I was looking for a manual way. Im looking through your source right now argo in the strtobit function, but frankly not understanding it. Sorry, I guess I turned into a thick designer...
actually flash does all the work for you:
code:
function strToBin(lqlstr) {
//create and array, each element in the array is a character of the string,
//so if you right "apple" the array is "a,p,p,l,e"
var charArray = lqlstr.split("");
var i = 0;
//i go through each element in the array and call the chartobin function for each element (that means i call the function for each letter
while (i<charArray.length) {
charArray[i] = (charToBin(charArray[i]));
i++;
}
return charArray.join("");
}
//take a character as a parameter
function charToBin(lqlchar) {
//get the character code (which is a number) of the letter
var code = lqlchar.charCodeAt(0);
//here, convert the code (number) to a number with base 2 (binary) and still, use it as a string
//then add 4 0000, just in case, to the beginning of the string (cause the minimum number it will return, is a 4 digit number (but i need 8 digits, for it to be a byte, i believe)
//so, you ll have something like "00001111"
//or "000012345678"
var bincode = "0000"+code.toString(2);
//here, i just make sure that the return code has 8 digits
//so if it is "00001234567" it will be cut to "01234567"
bincode = bincode.substr(-8, 8);
return bincode;
}
im not really good at explaining stuff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|