473,401 Members | 2,125 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,401 software developers and data experts.

Converting Char to ASCII

Hi,
In old asp I would just juse ASC('a') and that would give me the ASCII code
of that character, How can I do this in ASP.net

Having trouble finding the right class. :(
Nov 19 '05 #1
4 28927
I mean ANSI code

"dotnettester" wrote:
Hi,
In old asp I would just juse ASC('a') and that would give me the ASCII code
of that character, How can I do this in ASP.net

Having trouble finding the right class. :(

Nov 19 '05 #2
Hi,

You did not specify the language so I will assume C#, a simple cast will do
the job
int c = (int)'a';
You can also use the Convert class
int c = Convert.ToInt32('a');

For VB.NET the Convert class will work or you can use the VB.NET
implementation of Asc().

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"dotnettester" <do**********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Hi,
In old asp I would just juse ASC('a') and that would give me the ASCII code of that character, How can I do this in ASP.net

Having trouble finding the right class. :(

Nov 19 '05 #3
Don't forget the usual caveat that the above only works for ASCII
values between 1 and 127. Above that, and into Unicode, all bets are
off.

This doesn't matter for most practical applications, but do some
digging in this group for some amusing theological battles on this
topic.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #4
Chris Taylor wrote:
Hi,

You did not specify the language so I will assume C#, a simple cast
will do the job
int c = (int)'a';
You can also use the Convert class
int c = Convert.ToInt32('a');

For VB.NET the Convert class will work or you can use the VB.NET
implementation of Asc().

Hope this helps


This will return the character's Unicode codepoint, which is not
necessarily the same as the character's byte value in ANSI encoding --
whatever that's suppoed to be. Windows-1250? -1251? -1252?

To encode characters, use a appropriate System.Text.Encoding instance
instead

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #5

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

Similar topics

4
by: jagmeena | last post by:
Hello, I am sure this problem has been addressed before, however, I could'nt get a suitable solution to my problem. Hence I am posting here. Thanks a lot for all your help. The code I have is ...
11
by: Chris Online | last post by:
Hi all, I'm using C++ Builder5. I want to get data from an edit-box and send it to a development kit. The dev-kit can only receive char and no char* here's a part of my code: char* Data_byte...
1
by: Rajesh Kumar Mallah | last post by:
Hi , my current database in 7.3.4 is SQL_ASCII are there any benifits of coverting it to UNICODE encoding in 7.4 ? If so what is the process. Regds Mallah.
18
by: Marcio Kleemann | last post by:
I need to force the first letter of each word in a line of text to uppercase. The text comes from a TextBox control in a Web Form. I'm new to ..NET and am having a problem. Since I can't modify...
4
by: 0310889 | last post by:
I am doing my honours project at uni and have to use C programming and the IIC bus, not the best combination as I have never done that much programming and I had never heard of the IIC bus! Anyway,...
9
Thekid
by: Thekid | last post by:
How do you go about converting something to ASCII using python? I have an example below of some randomly generated text that would need converted: 96,114,101,106,60, Shift: 27 I don't know...
5
by: AZRebelCowgirl73 | last post by:
I am trying to accomodate for negative numbers, and as long as the negative is not being used, I have no problems with my input() ouput() and add() functions. I have tried this two different ways,...
2
by: joe shoemaker | last post by:
I would like to convert url into md5 hash. My question is that md5 hash will create collision at 2^64. If you do long(value,16), where value is the md5 hash string, would value returned from...
15
by: itdevries | last post by:
Hi, I'm trying to read some binary data from a file, I've read a few bytes of the data into a char array with ifstream. Now I know that the first 4 bytes in the char array represent an integer....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.