473,378 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 57330
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
by: Zach | last post by:
Can one convert Unicode to ASCII? If so, could you please give an example? Many thanks.
0
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
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.