hexadecimal value convert to extended ascii code.
-
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..
-
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..
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.
-
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..
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
-
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..
Or do you mean you have the value of a Unicode character in a string as hexadecimal and want to display the character?
-
Or do you mean you have the value of a Unicode character in a string as hexadecimal and want to display the character?
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..
-
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..
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.
-
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..
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.