Text to Binary Converter - Small Basic Featured Program
Ha! I saw an episode of "Big Bang Theory" where they were arguing over the binary translation of English (how many zeros and ones there should be).
Amir had made a Decimal to Binary converter that I featured, and I mentioned that a text to binary converter would be pretty sweet.
Well now (through the magic of Small Basic) Amir CPS has made it possible to have a conversation with zeros and ones that you have encoded in binary:
Get your geek on! Go translate this into English! You can double click this one line, and then copy all the text at once:
010000110110111101101101011011010110010101101110011101000010000001101111011011100010000001110100011010000110010100100000011000100110110001101111011001110010000001111001011011110111010101110010001000000110011001100001011101100110111101110010011010010111010001100101001000000110001101101111011011000110111101110010
In the tool, if your cursor gets pushed to the second line, press Delete to get it up to the top line, or else you'll get an error message. Instead of copying the full line above, you can paste in these four lines, one at a time, no spaces:
01000011011011110110110101101101011001010110111001110100001000000110111101101110001
0000001110100011010000110010100100000011000100110110001101111011001110010000001111
0010110111101110101011100100010000001100110011000010111011001101111011100100110100
10111010001100101001000000110001101101111011011000110111101110010
It's a text to binary and binary to text converter!
Import : FTK803
Small change in codes to handle "NewLine" character
Import : BTN178
And here's the code...
1.``GraphicsWindow``.`` Width `` = ``400
2.``GraphicsWindow``.`` Height `` = ``300
3.``GraphicsWindow``.`` Title `` = ``"Text to Binary : Binary to Text"
4.
5.`` TextBox `` = ``Controls``.``AddMultiLineTextBox``(``10``,``10``)
6.``Controls``.``SetSize``(``TextBox``,``380``,``250``)
7.`` ButtonTB `` = ``Controls``.``AddButton``(``"Convert to Binary"``,``10``,``265``)
8.`` ButtonBT `` = ``Controls``.``AddButton``(``"Convert to Text"``,``140``,``265``)
9.``Controls``.`` ButtonClicked `` = ``onClick
10.
11.`` Sub ``onClick
12.`` `` LastButton `` = ``Controls``.``LastClickedButton
13.`` `` If `` LastButton `` = `` "Button1" ``Then
14.`` ``ConvertToBinary``(``)
15.`` ``Else
16.`` ``ConvertToText``(``)
17.`` ``EndIf
18.``EndSub
19.`` Sub ``ConvertToBinary
20.`` `` String `` = ``Controls``.``GetTextBoxText``(``TextBox``)
21.`` `` For `` i `` = `` 1 `` To ``Text``.``GetLength``(``String``)
22.`` `` CharCode `` = ``Text``.``GetCharacterCode``(``Text``.``GetSubText``(``String``,``i``,``1``)``)
23.`` ``'convert ascii codes into binary
24.`` `` bit `` = ``""
25.`` `` binval `` = ``""
26.`` `` Count `` = ``0
27.`` `` While `` CharCode `` > ``0
28.`` ``bit``[``Count`` ] `` = ``Math``.``Remainder``(``CharCode``,``2``)
29.`` `` CharCode `` = ``Math``.``Floor``(`` CharCode `` / ``2``)
30.`` `` Count `` = `` Count `` + ``1
31.`` ``EndWhile
32.`` `` For `` j `` = ``Array``.``GetItemCount``(``bit`` ) `` To `` 0 `` Step ``-``1
33.`` `` binval `` = ``Text``.``Append``(``binval``,``bit``[``j``]``)
34.`` ``EndFor
35.`` ``'add leading zero to make binary value even
36.`` `` For `` b `` = `` 0 `` To `` 8 `` - ``Text``.``GetLength``(``binval``)
37.`` `` binval `` = ``Text``.``Append``(``0``,``binval``)
38.`` ``EndFor
39.`` `` longbin `` = ``Text``.``Append``(``longbin``,``binval``)
40.`` ``EndFor
41.`` ``Controls``.``SetTextBoxText``(``TextBox``,``longbin``)
42.`` `` longbin `` = ``""
43.``EndSub
44.`` Sub ``ConvertToText
45.`` `` Binary `` = ``Controls``.``GetTextBoxText``(``TextBox``)
46.`` `` If ``Math``.``Remainder``(``Text``.``GetLength``(``Binary``)``,``8`` ) ``<`` > `` 0 ``Then
47.`` ``GraphicsWindow``.``ShowMessage``(``"Binary is un even"``,``"Error"``)
48.`` ``Else
49.`` `` For `` g `` = `` 1 `` To ``Text``.``GetLength``(``Binary`` ) `` Step ``8
50.`` `` Binarychar `` = ``Text``.``GetSubText``(``Binary``,``g``,``8``)
51.`` ``'Convert binary to decimal
52.`` `` For `` bit_Count `` = `` 1 `` To ``Text``.``GetLength``(``Binarychar``)
53.`` `` binaryNum `` = `` binaryNum `` + ``Text``.``GetSubText``(``Binarychar``,``Text``.``GetLength``(``Binarychar``)``-``bit_Count``+``1``,``1``)``*``Math``.``Power``(``2``,``bit_Count``-``1``)
54.`` ``EndFor
55.`` ``'get char from ascci code
56.`` `` Char `` = ``Text``.``GetCharacter``(``binaryNum``)
57.`` `` binaryNum `` = ``""
58.`` ``'append char
59.`` `` LongString `` = ``Text``.``Append``(``LongString``,``Char``)
60.`` ``EndFor
61.`` ``Controls``.``SetTextBoxText``(``TextBox``,``LongString``)
62.`` `` LongString `` = ``""
63.`` ``EndIf
64.``EndSub
What do you think?
Do you need a Klingon to Binary converter? =^)
Based on the forum thread, the community added more similar converters...
Updated version from Amir:
Version with Base-64 Conversion from WhTurner:
Ternery to Text Converter from Math Man:
Hex to Text Converter from Amir:
See our forum thread conversation about this Binary converter.
Enjoy!
- Ninja Ed
Comments
Anonymous
February 01, 2013
01100111011001010110010101101011011110010010000001100011011011110110111101101100Anonymous
February 01, 2013
The comment has been removedAnonymous
February 01, 2013
In response to the first binary string, 01001111011100100110000101101110011001110110010100101100001000000110111101110010001011000010000001101001011001100010000001111001011011110111010100100000011011000110100101101011011001010010110000100000001100000011000100110000001100000011000100110001001100010011000100110000001100010011000100110001001100000011000000110001001100000011000000110001001100010011000000110000001100000011000000110001001100000011000100110001001100000011000100110001001100010011000000110000001100010011000100110000001100000011000100110001001100010011000000110001001100010011000000110000001100010011000000110001Anonymous
February 01, 2013
So, 0110011101100101011001010110101101111001001000000110111001100101011100100110010001110011001000000110000101110010011001010010000001110000011100100110010101110100011101000111100100100000011000010111011101100101011100110110111101101101011001010010110000100000011000010111001100100000011011110110111001101100011110010010000001100111011001010110010101101011011110010010000001101110011001010111001001100100011100110010000001101011011011100110111101110111Anonymous
February 01, 2013
i didn't understand a single thing ... :PAnonymous
February 02, 2013
You can use the Text -> Binary Converter made by Amir CPS mentioned above.Anonymous
February 03, 2013
Yashika, Go here: smallbasic.com/.../program Then enter text and convert it into Binary (zeros and ones). That's the first step. =^)Anonymous
February 03, 2013
01000110010101000100101100111000001100000011001100100000001110100010000001010101011100000110010001100001011101000110010100001101000010100100000101101110011001000010000001101101011110010010000001100110011000010111011001101111011101010111001001101001011101000110010100100000011000110110111101101100011011110111001000100000011010010111001100100000010000100110110001100001011000110110101100101110Anonymous
February 03, 2013
01011001011000010111001101101000011010010110101101100001001000000110100101110011001000000110110101111001001000000111001101101001011100110111010001100101011100100010000001100001011011100110010000100000011001000110111101101110001001110111010000100000011010110110111001101111011101110010000001110011011010010110111001100111011011000110010100100000011101000110100001101001011011100110011100100000011000010110001001101111011101010111010000100000011000110110111101101101011100000111010101110100011001010111001000100000011000100111010101110100001000000110111101101110011011000111100100100000011001110110000101101101011001010111001100101110Anonymous
February 03, 2013
01010111011010000110000101110100001000000110100101110011001000000111010001101000011001010010000001101101011001010110000101101110011010010110111001100111001000000010000000100010001101000110110101101001011100100010001000111111Anonymous
February 04, 2013
01000001011011010110100101110010Anonymous
February 04, 2013
0100001101010000010100110010000001110011011101000110000101101110011001000111001100100000011001100110111101110010001000000100001101101001011101000111100100100000010100000111010101100010011011000110100101100011001000000101001101100011011010000110111101101111011011000010000001100001011011100110010000100000011011100110111101110111001000000110100100100000011001110110111101110100001000000110000101100100011011010110100101110011011100110110100101101111011011100010000001101001011011100010000001100001001000000110111001100101011101110010000001110011011000110110100001101111011011110110110000101110Anonymous
February 04, 2013
010000010110110101101001011100100010000001101001011100110010000001100001001000000100100001100101011000100111001001100101011101110010000001110111011011110111001001100100001000000111011101101000011010010110001101101000001000000110110101100101011000010110111001110011001000000101010001110010011001010110010100100000010101000110111101110000001000000110111101110010001000000100101101101001011011100110011100101110Anonymous
February 04, 2013
010000010110110101101001011100100010110000100000010010010010000001110101011100000110010001100001011101000110010101100100001000000111010001101000011001010010000001101001011011100111000001110101011101000010000001100011011011110110010001100101001000000110000101101110011001000010000001110100011010000110010100100000011011000110100101101110011010110010000001101001011011100010000001110100011010000110010100100000011000100110110001101111011001110010000001110000011011110111001101110100001000000110000101100010011011110111011001100101001000000010100001110100011011110010000001000110010101000100101100111000001100000011001100101001001011100010000001010100011010000110000101101110011010110111001100100001Anonymous
February 04, 2013
010000010110110101101001011100100010110000100000001010000101010001101111011100000010000001101111011100100010000001001011011010010110111001100111001010010010000001110110011001010111001001111001001000000110011101110010011001010110000101110100001000000100111001100001011011010110010100100001Anonymous
February 05, 2013
010011100110000101101111011000110110100001100001011011100100111101001110001011000010000001110111011010000110000101110100001000000110100101110011001000000111100101101111011101010111001000100000011001100110000101110110011011110111001001101001011101000110010100100000011000110110111101101100011011110111001000111111Anonymous
February 05, 2013
0100110101111001001000000110011001100001011101100110111101110010011000010111010001100101001000000110001101101111011011000110111101110010001000000110100101110011001000000100011001101001011001010110110001100100001000000110110101110101011100110111010001100001011100100110010000100000011110010110010101101100011011000110111101110111001011100010000000101000010110010110010101101100011011000110111101110111001000000110100101110011001000000111010001101000011001010010000001100011011011110110110001101111011100100010000001101111011001100010000001100101011000010111001001101100011110010010000001110011011100000111001001101001011011100110011100101001Anonymous
February 06, 2013
01001001001000000110000101100100011001000110010101100100001000000111010001101000011001010010000001010100011001010111100001110100001000000111010001101111001000000100001001101001011011100110000101110010011110010010000001000011011011110110111001110110011001010111001001110100011001010111001000100000011101000110111100100000011101000110100001100101001000000101001101101101011000010110110001101100001000000100001001100001011100110110100101100011001000000101000001110010011011110110011101110010011000010110110101110011001000000100011101100001011011000110110001100101011100100111100100101100001000000110100001100101011100100110010100111010 blogs.msdn.com/.../small-basic-program-gallery.aspxAnonymous
February 14, 2013
02201010121012110201102011020210201010120221210121110221021201012022121012111002011101102101012100101020211020110021012111020111110101210200110101100211101102021102011022102021102001201 smallbasic.com/.../programAnonymous
February 14, 2013
4920616464656420416D697227732048657820436F6E76657274657220746F207468697320626C6F6720706F73743A smallbasic.com/.../program