dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

SerialPort.Write with byte[] buffer does not encode characters

Open 5andr0 opened this issue 3 years ago • 2 comments

Summary

By default, SerialPort uses ASCIIEncoding to encode the characters. ASCIIEncoding encodes all characters greater than 127 as (char)63 or '?'. To support additional characters in that range, set Encoding to UTF8Encoding, UTF32Encoding, or UnicodeEncoding.

This statement in the remarks section of the prototype Write (byte[] buffer, int offset, int count); is false and should be removed. The byte[] buffer will not be encoded!

There has been some confusion: https://stackoverflow.com/questions/32864198/can-i-use-serialport-write-to-send-byte-array

5andr0 avatar Jan 10 '22 17:01 5andr0