How to apply encoding when reading from a serial port
- by rross
I'm reading data from a serial port. I read this posting: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a709d698-5099-4e37-9e10-f66ff22cdd1e
He is writing about many of the issues I have encounter, but in his writing he refers to using: System.Text.Encoding.GetEncoding("Windows-1252"). The problem I'm having is when and how to apply this. There are three potitional spots in my opinion. When the serial port object is define:
private SerialPort comport = new SerialPort();
The Event handler:
comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
Or when reading the data:
string data = comport.ReadExisting();
No matter where I add it. I seem to get errors. How would one use Encoding?