I have a program that uses ACS() to extract a byte from a string recieved via a dll:
These two lines create the string ReadString from a usb device: (the string is created from 7 bytes recieved from the usb device)
ReadString = " "
ftResult = FT_Read(ftHandle, ReadString, 7, bytesRead)
and then this (and similar code) extracts the byte values
ver1 = Asc(Mid(ReadString, 5, 1))
The code has worked fine for years ( I've verified that every possible byte value is correctly received),but now one user installing on a new laptop with windows 10 is experiencing this error:
System.ArgumentException: The output byte buffer is too small to contain the encoded data, encoding 'Unicode (UTF-8)' fallback 'System.Text.EncoderReplacementFallback'.
Parameter name: bytes
at Microsoft.VisualBasic.Strings.Asc(Char String)
What I have tried:
I've googled for days now and gone down a few rabbit holes, but what I think I've narrowed it down to is that most machines encode the string ReadString as UTF16 (VB.net says this is the default) and this particular user's machine is encoding ReadString as UTF-8.
I was hoping to force my code to use UTF-16 regardless of the machine used but can't figure out how to achieve this and I'm also worried that the DLL that is call to recieve the string might be using it's own encoding that I can't change.
Anyone have any useful guidance on this?