473,503 Members | 12,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hex to ascii conversion

hi to all,

i just need to convert a hex string, let's say "00" or "16" or "FF" that i
get from a file
and display the ascii character equivalent.

How i can do this ??

thanks a lot form any help

objectref
Nov 16 '05 #1
4 57352
Hi objectref,

You can use the Convert.ToInt32(string, base) to get the number value of a
hexadecimal string

int n = Convert.ToInt32("FF", 16);

To convert it to a character, simply cast the integer to char

char c = (char)n;

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Ok, Morten,

it is workimg ok!

thanks a lot for your help! I was up to a mess with the Encoding class
thanks again!

objectref
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opsnfd99aaklbvpo@pbn_computer...
Hi objectref,

You can use the Convert.ToInt32(string, base) to get the number value of a
hexadecimal string

int n = Convert.ToInt32("FF", 16);

To convert it to a character, simply cast the integer to char

char c = (char)n;

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #3
Does this work?

string str = "FF";
char c= Int32.Parse(str, NumberStyles.AllowHexSpecifier);

Regards
Senthil

Nov 16 '05 #4
yeap!!

with a cast change:
char c= (char) Int32.Parse(str, NumberStyles.AllowHexSpecifier);

thanks a lot !
"sadhu" <se**********@wdevs.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Does this work?

string str = "FF";
char c= Int32.Parse(str, NumberStyles.AllowHexSpecifier);

Regards
Senthil

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
27149
by: Zach | last post by:
Can one convert Unicode to ASCII? If so, could you please give an example? Many thanks.
0
1072
by: Mike | last post by:
I have a device that is supposed to send diameter data through the serial port. Somehow, this diameter data is being converted to a character - specifically the character 141 8D. Is the data...
1
1467
by: Aparna Sinha via .NET 247 | last post by:
Dear All, How do we get ascii equivalent of any character in C#.Please give a C# example with relevant name spaces.. -------------------------------- From: Aparna Sinha -----------------------...
0
1006
by: Jon Paal | last post by:
text entered as ascii in a text box as "•" is converted to "&amp;#149;" how do I stop the conversion of the ampersand ?
3
5372
by: AlekseyUS | last post by:
Hi All, I'm writing a program, part of which needs to read text from a .log file in UNICODE line by line, then convert it to ASCII and write it to an ASCII .log file line by line... I've been...
14
7951
by: Peter Sprenger | last post by:
Hello, I want to efficient convert floating point numbers (IEEE754) into a string. I have no library routines that do the job (like sprintf etc.), because I work in an embedded environment. ...
10
19029
by: barmatt80 | last post by:
I have a xml file that I import to access and I have two fields that are in the hex format. Is there away to convert those fields to text within access? I am thinking to do it after the import or...
1
1745
by: jmash | last post by:
Hello, I have a string "00460069006E0061006C" that is in Hexadecimal that needs to be converted as "Final" which is the translation of Hexadecimal. Do you know how to convert the Hex to readable...
1
2584
by: Vic | last post by:
I have a c program which writes mac address entries onto a text file. Text file when opened in vim looks like this index mac 1 ^@^@^Q^@^@^A ascii of (00.00.11.00.00.01) 2 ^@^@^Q^@^@^B...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.