Extended ASCII in C#

Posted on 2011-10-19
Last Modified: 2012-05-12
Hello Experts,

I have a string with extended characters in it.

string   str = "›¥›";

When I convert into Byte, it's  byte value is different:
System.Text.Encoding ascii = System.Text.Encoding.ASCII;
                            Byte[] encodedBytes = ascii.GetBytes(str );

All the extended characters are converted into  ?(Question Mark), instead of their original extended characters.

Result:: ???
encodeBytes[0]   char is ' ?' and value is 63. // Instead '>' and value 155
encodeBytes[1]   char is  '?' and value is 63. // Instead '¥' and value 165
encodeBytes[2]   char is  '?' and value is 63. // Instead '>' and value 155

Question by:ASPDEV
    LVL 82

    Expert Comment

    by:Dave Baldwin
    ASCII is defined as the lowest 7-bit character set.  It doesn't have any characters with a value greater than 127.  "Extended ASCII" is as term kind of leftover from DOS days.  Now we have "Character sets".  My best reference for that is .  Here is the Microsoft page for "System.Text.Encoding".
    LVL 2

    Expert Comment


    System.Text.Encoding ascii = System.Text.Encoding.Unicode;

    That should do the trick.
    LVL 2

    Accepted Solution

    Try this also.

    System.Text.Encoding ascii = System.Text.Encoding.Default;


    Author Closing Comment


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now