[ACCEPTED]-How can I convert extended ascii to a System.String?-extended-ascii

Accepted answer
Score: 29

Byte 189 represents a "½" in iso-8859-1 9 (aka "Latin-1"), so the following is maybe 8 what you want:

var e = Encoding.GetEncoding("iso-8859-1");
var s = e.GetString(new byte[] { 189 });

All strings and chars in .NET 7 are UTF-16 encoded, so you need to use an 6 encoder/decoder to convert anything else, sometimes 5 this is defaulted (e.g. UTF-8 for FileStream 4 instances) but good practice is to always 3 specify.

You will need some form of implicit 2 or (better) explicit metadata to supply 1 you with the information about which encoding.

Score: 14

The old PC-8 or Extended ASCII character 14 set was around before IBM and Microsoft 13 introduced the idea of Code Pages to the 12 PC world. This WAS Extended ASCII - in 1982. In 11 fact, it was the ONLY character set available 10 on PC's at the time, up until the EGA card 9 allowed you to load other fonts in to VRAM.

This 8 was also the default standard for ANSI terminals, and 7 nearly every BBS I dialed up to in the 80's 6 and early 90's used this character set for 5 displaying menus and boxes.

Here's the code 4 to turn 8-bit Extended ASCII in to Unicode 3 text. Note the key bit of code: the GetEncoding("437"). That 2 used Code Page 437 to translate the 8-bit 1 ASCII text to the Unicode equivalent.

    string ASCII8ToString(byte[] ASCIIData)
        var e = Encoding.GetEncoding("437");
        return e.GetString(ASCIIData);
Score: 13

It depends on exactly what the encoding 7 is.

There's no such thing as "ASCII 189" - ASCII 6 only goes up to 127. There are many encodings 5 which a 8-bit encodings using ASCII for 4 the first 128 values.

You may want Encoding.Default (which is 3 the default encoding for your particular 2 system), but it's hard to know for sure. Where 1 did your data come from?

Score: 1

System.String[] can not store characters with ASCII > 127 if you are 3 trying to work on any extended ASCII characters 2 such as œ ¢ ½ ¾here is the method to convert it into 1 their binary and decimal equivalent

More Related questions