473,651 Members | 2,792 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 57370
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:opsnfd99aa klbvpo@pbn_comp uter...
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.Al lowHexSpecifier );

Regards
Senthil

Nov 16 '05 #4
yeap!!

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

thanks a lot !
"sadhu" <se**********@w devs.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Does this work?

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

Regards
Senthil

Nov 16 '05 #5

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

Similar topics

7
27157
by: Zach | last post by:
Can one convert Unicode to ASCII? If so, could you please give an example? Many thanks.
0
1075
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 automatically converted or something when I use the ReadFile function?
1
1470
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 ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/) <Id>5BXpXnTmakCCCY2hJXG2gQ==</Id>
0
1011
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
5392
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 battling with this issue for a week, and have yet to find a solution. PS: I'm writing in C Thanks a lot
14
7973
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. My actual algorithm uses multiplying with 10 to shift the fraction into an integer value and to aquire the used exponent. But the drawback is obvious: When I have very small numbers like 3.141E-300 I have to make 300 time consuming floating point...
10
19089
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 should I do it on import? Thanks, Also thanks for all previous help, much appreciated.
1
1750
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 string? Thanks, jmash
1
2600
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 ascii of (00.00.11.00.00.02) .. ........ Likewise I read the mac entries from the text file using a perl script and do some processing
0
8352
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7297
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
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 we have to send another system
1
1909
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.