fasteddy516 / SimplySerial

A windows console application for serial communications.
MIT License
193 stars 23 forks source link

Support for high ASCII and Unicode? #24

Closed aderusha closed 1 year ago

aderusha commented 1 year ago

I'm trying to figure out how to get SS to display extended character sets and am not 100% sure that I'm even doing this right. I'm running under Terminal on Windows 11 and I note that SS does not seem to be able to render anything apart from the first 127 chars of ASCII character set. High ASCII block drawing chars and UTF-8 don't seem to be working correctly.

Here's some output as it appears in PuTTY, utilizing CaskaydiaCove Nerd Font Mono which should be a reasonably-complete character set:

Note that °F, µg/m³, and m/s² all render correctly here

Here's an example of similar output utilizing SS.exe in Windows Terminal, again with CaskaydiaCove Nerd Font Mono. Note the text being sent as 66.20000 °F renders as 66.20000 ??F in SS. Other not-7-bit-ASCII chars all similarly render as ??.

Now I hit Ctrl+X to exit SS.exe, and in the same terminal session I copy/paste from PuTTY to spit output back to the screen.

This suggests that Windows Terminal is able to correctly display these glyphs when asked to do so.

fasteddy516 commented 1 year ago

First of all, thank you for taking the time to do all of that testing and generate those screenshots and detailed descriptions, it is sincerely appreciated!

You are absolutely correct - Windows Terminal appears to have no problem handling the full unicode character set so long as the selected font has the required glyphs. I did some digging, and the fix for SimplySerial is twofold:

1) The application has to be configured to output in UTF8 instead of ASCII. This is the easy part; all I have to do is add a single line of code: Console.OutputEncoding = System.Text.Encoding.UTF8. I have already tested this and it works.

2) Incoming serial data has to be interpreted as UTF-8. This is the harder part, and where my relative inexperience with .NET and C# shows; I'll have to figure out how to interpret the incoming stream of data as variable-length unicode characters rather than just a sequence of bytes.

I'll try to work on it over the next day or two and let you know when I've got a solution.

fasteddy516 commented 1 year ago

I've implemented unicode support (and a few other small items) and published a beta version of SimplySerial here. Please give it a try when you have a chance and let me know if you have any issues. I'll publish it as a stable release assuming there are no problems.

Thanks again for the report and suggestion - I never realized how much I was missing unicode support until now! ;)

aderusha commented 1 year ago

My brother that worked AWESOME! Everything is gravy now, and holy cow what a fast fix. I really love this tool, thanks for the continued development and unicode support!