Converting Char to ASCII

Discussion in 'ASP .Net' started by =?Utf-8?B?ZG90bmV0dGVzdGVy?=, Aug 15, 2005.

  1. 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. :(
    =?Utf-8?B?ZG90bmV0dGVzdGVy?=, Aug 15, 2005
    #1
    1. Advertising

  2. 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. :(
    =?Utf-8?B?ZG90bmV0dGVzdGVy?=, Aug 15, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?ZG90bmV0dGVzdGVy?=

    Chris Taylor Guest

    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" <> wrote in message
    news:...
    > 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. :(
    Chris Taylor, Aug 15, 2005
    #3
  4. =?Utf-8?B?ZG90bmV0dGVzdGVy?=

    jasonkester Guest

    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/
    jasonkester, Aug 15, 2005
    #4
  5. =?Utf-8?B?ZG90bmV0dGVzdGVy?=

    Joerg Jooss Guest

    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:
    Joerg Jooss, Aug 17, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Online

    Converting char* to char

    Chris Online, Feb 17, 2004, in forum: C++
    Replies:
    11
    Views:
    659
    Chris Online
    Feb 19, 2004
  2. lovecreatesbeauty
    Replies:
    1
    Views:
    1,043
    Ian Collins
    May 9, 2006
  3. Alan
    Replies:
    4
    Views:
    743
    Marcus Kwok
    May 23, 2007
  4. someone
    Replies:
    37
    Views:
    2,502
    Joshua Maurice
    Oct 18, 2011
  5. Nick Bo
    Replies:
    8
    Views:
    203
    Greg Barozzi
    Oct 30, 2009
Loading...

Share This Page