For some reason when I type "Encoding." in to VS all there is UTF8, Equals, and ReferenceEquals. Does anyone know why I can't use ASCII? I need to convert serial data from bytes[] to Char[] or String.
I'm using .net framework 4.1
For some reason when I type "Encoding." in to VS all there is UTF8, Equals, and ReferenceEquals. Does anyone know why I can't use ASCII? I need to convert serial data from bytes[] to Char[] or String.
I'm using .net framework 4.1
This worked for me when I created a UDP message sender/receiver.
using System.Text;
//converts string/char into ASCII
byte[] encoding = System.Text.ASCIIEncoding.ASCII.GetBytes("Hello, World!");
//converts ASCII into string
Console.Write(Encoding.ASCII.GetString(encoding));
ASCII encoding is subsumed by UTF-8 -- You should not be attempting to use ASCII encoding in network/Bluetooth transport systems. ASCII is a legacy encoding (used extensively in RS-232 communications) and does not use the MSB -- so a value of 160 -- is not possible in ASCII...127 is the maximum value available in ASCII.
You can use ASCII all day long in your sandbox, but -- you cannot use it on a wired/wireless transport.
Use UTF-8 instead.