I have a need to send bytes through the serial port and wanted to do this using the convenience of the C# class SerialPort. However it apperas there is a severe restriction on sending raw bytes through the serial port using this class as, quoting from the ASCIIEncoding class docs:
ASCIIEncoding corresponds to the Windows code page 20127. Because ASCII is a 7-bit encoding, ASCII characters are limited to the lowest 128 Unicode characters, from U+0000 to U+007F. If you use the default encoder returned by the Encoding.ASCII property or the ASCIIEncoding constructor, characters outside that range are replaced with a question mark (?) before the encoding operation is performed.
This is NOT what I want. If I have a byte value greated than 0x7F I want it sent as that value, NOT encoding as a question mark. I cannot use UTF-8 encoding as this can introduce more bytes for characters which my receiving device does not expect. Both SerialPort.Write Method (Char[], Int32, Int32) and (stupidly in my opinion) SerialPort.Write Method (Byte[], Int32, Int32) encode the data prior to transmission.
It appears that I can create my own EncoderFallback class but from my understanding this only allows me to specify another character to use instead of '?' or am I incorrect in assuming this?
So is it at all possible to send bytes that have NOT been interferred with via the SerialPort class?