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
  1. Home
  2. General Programming
  3. C#
  4. hexadecimal value convert to extended ascii code.

hexadecimal value convert to extended ascii code.

Scheduled Pinned Locked Moved C#
helptutorial
7 Posts 5 Posters 0 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.
  • K Offline
    K Offline
    kamalesh5743
    wrote on last edited by
    #1

    Hi all, How to convert hex value to extended ascii code and the output should be show in richtextbox.Pls help me.Thank you 2 all..

    L A P G 4 Replies Last reply
    0
    • K kamalesh5743

      Hi all, How to convert hex value to extended ascii code and the output should be show in richtextbox.Pls help me.Thank you 2 all..

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

      Hi, int.ToString("X8"); is what I use normally. Not sure why you mention extended ASCII, it's only digits and letters after all. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


      1 Reply Last reply
      0
      • K kamalesh5743

        Hi all, How to convert hex value to extended ascii code and the output should be show in richtextbox.Pls help me.Thank you 2 all..

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        Well, you pretty much want hex -> int -> ascii right? Well, you can use Convert.ToInt32, like this:

        string hex = "0x0F";
        int num = 0;
        num = Convert.ToInt32(hex, 16);

        The first parameter is the string containing the number, and the second is the base. ie Hex is base 16 and normal int's are base 10. Binary is base 2. So, now that you have a number cast it as a char, that should give you your ascii character. If you want to build a string, then set up an array of bytes, and fill it with the results from your Convert.ToInt32; you can then get a string from the array by using Encoding.ASCII.GetString(arrayOfBytes); And, of course, these could have been easily found out by typing something like "c# hex to ascii" or "c# hex to int" something like that. EDIT: Oh, and you can figure out how to get it into the rich text box yourself right? Good.

        My current favourite word is: Nipple!

        -SK Genius

        1 Reply Last reply
        0
        • K kamalesh5743

          Hi all, How to convert hex value to extended ascii code and the output should be show in richtextbox.Pls help me.Thank you 2 all..

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Or do you mean you have the value of a Unicode character in a string as hexadecimal and want to display the character?

          K 1 Reply Last reply
          0
          • P PIEBALDconsult

            Or do you mean you have the value of a Unicode character in a string as hexadecimal and want to display the character?

            K Offline
            K Offline
            kamalesh5743
            wrote on last edited by
            #5

            No.Actually i want display ascii character in richtextbox.As a example,in richtextbox i wanna draw rectangle using this ascii char.So i need convert hexadecimal num to ascii char..

            P 1 Reply Last reply
            0
            • K kamalesh5743

              Hi all, How to convert hex value to extended ascii code and the output should be show in richtextbox.Pls help me.Thank you 2 all..

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              This is what you are asking for: string hex = "B8"; int code = Convert.ToInt32(hex, 16); SomeRichTextBox.Text = Encoding.Default.GetString(new byte[] { (byte)code } ); This will convert a string containing the hexadecimal representation of a number into a number, then it will use the current ANSI encoding of the system to turn that number into a character.

              Despite everything, the person most likely to be fooling you next is yourself.

              1 Reply Last reply
              0
              • K kamalesh5743

                No.Actually i want display ascii character in richtextbox.As a example,in richtextbox i wanna draw rectangle using this ascii char.So i need convert hexadecimal num to ascii char..

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                Oh, the line drawing characters? OK, I just tried it and found that Ariel won't do it, but I changed my RichTextBox to use Courier New and it works. So it's a matter of the typeface in use.

                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