Is it possible to read extended ASCII from the serial port? My project requires that Serial.read() be able to accept extended ASCII characters (0x80 &lt;=&gt; 0xFF). For example, I would expect reading the character ¥ to yield the decimal value 157. Instead, the read() command has two successful reads, with the values: 194 and 165. Of course, I could create a lookup table and convert, but this is not a viable option. I am conforming to the Grbl standard protocol, which uses these single-byte extended ASCII characters as interrupts. Such a two-byte structure precludes a simple peek/read approach necessitated by the protocol.
Edit I tried to simplify the question for this context, but failed to account for the fact that the Arduino IDE will send the input as Unicode. Regardless, it still does not work when sending bytes directly. Namely, if I send the byte 0x93 via C# as Serial.Write(&quot;\u0093&quot;), the Arduino's Serial.read() does not see any bytes available. Sending normal ASCII, e.g., Serial.Write(&quot;\u0018&quot;), works fine.
Yes, of course, you can read any byte sequence. As you have experienced,
if you send the byte values 194 and 165, your Arduino reliably reads 194
and 165.
Now, you have to be aware that there are tons of incompatible character
encodings that could all be called “extended ASCII”. I do not know which
one you have in mind. Maybe there is such an encoding where “¥” has the
code point 157. Nowadays, however, almost any modern computer system
uses Unicode, and serializes the characters using UTF-8. The character
“¥” is serialized in UTF-8 as the pair of bytes 194 and 165.
If you want to use the Grbl protocol, send interrupts as bytes, do not
think about them as “characters”.