Problems with chr(&HC0) in

When I send chr(&HCO) out the serial port, I see 0x3F.  This does not happen when I send chr(&H7F) out the port on any other hex value less than 0x7F.  It appears to be an overflow issue.  Can you help?
gmcorbeSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Try sending ChrW(&HC0), instead of Chr.  That would be the Unicode representation for the character, instead of the ANSI representation (&H7F and lower).
gmcorbeSoftware DeveloperAuthor Commented:
Thanks for responding.  I already tried that.  I believe you are correct in that it's an encoding issue with the serial port in that if I send anything beyond the normal ASCII data set (0-0x3F or 0-127), it freaks and sends out the maximum 7-bit value of 0x3F.  I'm studying encoding for a serial port now.  THANKS.
Bob LearnedCommented:
Oh, yeah, it uses AsciiEncoding by default (d'oh).

 port.Encoding = System.Text.Encoding.Default
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

gmcorbeSoftware DeveloperAuthor Commented:
We're getting closer.

If I use port.Encoding = System.Text.UnicodeEncoding, I see a 0xC0 0x00 out the serial port.
System.Text..UTF7, System.Text.UTF8 did not work either.

Bob LearnedCommented:
What code page are you using?  United States is typically 1252.

port.Encoding = System.Text.Encoding.GetEncoding(1252)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gmcorbeSoftware DeveloperAuthor Commented:
IT WORKED.  THANKS.  I originally used the encoding described in blog which indicated to use mySerialPort.Encoding = Encoding.GetEncoding(28591);  which is Western European (ISO) encoding.  This code page worked for the 0xC0 char but failed with other characters.  Your code page is working for all characters!!!!!!!!!!  NOTE that the URL blog is good reading anyway.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.