Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Conversion to Binary Language (Not file or .bin)

Conversion to Binary Language (Not file or .bin)

Scheduled Pinned Locked Moved IT & Infrastructure
helptutorial
9 Posts 5 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zaid Pirwani
    wrote on last edited by
    #1

    Hi there, I just want to ask if there is anyway to convert a file (any file, any format) into binary language and I do mean the real binary language having only 1s and 0s. For the sake of convenience, can anyone please tell me ways to convert text files (I think those are the most simplest of all file formats) into binary language. Please guys, share what you know, I have no idea how to do this conversion, but I have some great ideas on how to work with that stuff, its all still just a fancy thought, but if it works, it will create something entirely NEW. Thanks to all in advance who will help me on this subject.

    Z S J 3 Replies Last reply
    0
    • Z Zaid Pirwani

      Hi there, I just want to ask if there is anyway to convert a file (any file, any format) into binary language and I do mean the real binary language having only 1s and 0s. For the sake of convenience, can anyone please tell me ways to convert text files (I think those are the most simplest of all file formats) into binary language. Please guys, share what you know, I have no idea how to do this conversion, but I have some great ideas on how to work with that stuff, its all still just a fancy thought, but if it works, it will create something entirely NEW. Thanks to all in advance who will help me on this subject.

      Z Offline
      Z Offline
      Zaid Pirwani
      wrote on last edited by
      #2

      I just want to know the method of converting a text file, sample code would be highly appreciated, there is no specific programming language in my mind, any programming language will work.

      1 Reply Last reply
      0
      • Z Zaid Pirwani

        Hi there, I just want to ask if there is anyway to convert a file (any file, any format) into binary language and I do mean the real binary language having only 1s and 0s. For the sake of convenience, can anyone please tell me ways to convert text files (I think those are the most simplest of all file formats) into binary language. Please guys, share what you know, I have no idea how to do this conversion, but I have some great ideas on how to work with that stuff, its all still just a fancy thought, but if it works, it will create something entirely NEW. Thanks to all in advance who will help me on this subject.

        S Offline
        S Offline
        Sebastian Schneider
        wrote on last edited by
        #3

        I believe you may have fallen for a prank someone played on you. Or a misunderstanding. Or I've fallen for your joke. Everything in a digital system is stored as 1 and 0. However, noone writes it out. If you use a hex-editor to look at a file, you'll see, for example "A5", but stored as "10100101" on the disk. Really.

        Z 2 Replies Last reply
        0
        • S Sebastian Schneider

          I believe you may have fallen for a prank someone played on you. Or a misunderstanding. Or I've fallen for your joke. Everything in a digital system is stored as 1 and 0. However, noone writes it out. If you use a hex-editor to look at a file, you'll see, for example "A5", but stored as "10100101" on the disk. Really.

          Z Offline
          Z Offline
          Zaid Pirwani
          wrote on last edited by
          #4

          NO I have not fallen to any ones prank, nor I intend to pull a prank on you. I know that everything in this digital world of computers is in 1s and 0s, but is there any way to actually see all those 1s and 0s of a file, I mean since everything is interpreted by computers as 1 and 0 then why can't we see them, there can be a way of seeing all those digits, I want to know how information is really stored.

          1 Reply Last reply
          0
          • S Sebastian Schneider

            I believe you may have fallen for a prank someone played on you. Or a misunderstanding. Or I've fallen for your joke. Everything in a digital system is stored as 1 and 0. However, noone writes it out. If you use a hex-editor to look at a file, you'll see, for example "A5", but stored as "10100101" on the disk. Really.

            Z Offline
            Z Offline
            Zaid Pirwani
            wrote on last edited by
            #5

            And I cannot use Hex editor to view the 1s and 0s, if ther is a way then please do tell me.

            L L 2 Replies Last reply
            0
            • Z Zaid Pirwani

              And I cannot use Hex editor to view the 1s and 0s, if ther is a way then please do tell me.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You can see them, once you know how to. The hex-values are the actual values, representing the binary values. There are a lot of ways to write down the number twelve; * Twelve * 12 * C (=12, but written in hex) * 14 (that's twelve, but written in oct) * 1100 (=8 + 4, written in bin) * XII (ancient encoding) That's the same number, over and over again. Now, it's hard to read "1100", so we use the decimal "12" whenever we talk about twelve. A hex-representation shows "16" bits in a single character. Open your hex-editor, take two hex-characters. Convert them to "binary", by writing them out (meaning, a "C" becomes "00001100") and you'll have the actual 0's and 1's that are stored.

              I are troll :)

              1 Reply Last reply
              0
              • Z Zaid Pirwani

                And I cannot use Hex editor to view the 1s and 0s, if ther is a way then please do tell me.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Hi, thie C# snippet will show bits and bytes:

                FileStream fs=File.Open(filename, FileMode.Open);
                for (long adr=0; ; adr++) {
                	int byteValue=fs.ReadByte();
                	if (byteValue<0) break;
                	string s="\["+adr.ToString()+"\]=";
                	for (int mask=0x80; mask!=0; mask/=2) s=s+((byteValue&mask)==0?"0":"1");
                	log(s);
                }
                fs.Close();
                log("Done");
                

                when you provide a log(string) method to output a line of text. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                Z 1 Reply Last reply
                0
                • L Luc Pattyn

                  Hi, thie C# snippet will show bits and bytes:

                  FileStream fs=File.Open(filename, FileMode.Open);
                  for (long adr=0; ; adr++) {
                  	int byteValue=fs.ReadByte();
                  	if (byteValue<0) break;
                  	string s="\["+adr.ToString()+"\]=";
                  	for (int mask=0x80; mask!=0; mask/=2) s=s+((byteValue&mask)==0?"0":"1");
                  	log(s);
                  }
                  fs.Close();
                  log("Done");
                  

                  when you provide a log(string) method to output a line of text. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                  Z Offline
                  Z Offline
                  Zaid Pirwani
                  wrote on last edited by
                  #8

                  thanks, let me work on this, I will write back when I succeed.

                  1 Reply Last reply
                  0
                  • Z Zaid Pirwani

                    Hi there, I just want to ask if there is anyway to convert a file (any file, any format) into binary language and I do mean the real binary language having only 1s and 0s. For the sake of convenience, can anyone please tell me ways to convert text files (I think those are the most simplest of all file formats) into binary language. Please guys, share what you know, I have no idea how to do this conversion, but I have some great ideas on how to work with that stuff, its all still just a fancy thought, but if it works, it will create something entirely NEW. Thanks to all in advance who will help me on this subject.

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #9

                    Pass me that left handed screwdriver, and go fetch me the long weight from the store cupboard and we'll go from there.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups