Asc(string character) returns wrong value chinese win10 machine
-
Use
AscW
instead.AscW
returns the Unicode code point for the input character. … The returned value is independent of the culture and code page settings for the current thread.(The documentation is for VB.NET, but the same comments apply to VB6.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thanks Homer. I tried AscW(string) but I still get the same error. For example: instead of reading 0 22 129 0 22 in the chinese PC I get 63 63 63 0 0 I also tried changing the regional settings in the PC to English but that did not work either.
-
Thanks Homer. I tried AscW(string) but I still get the same error. For example: instead of reading 0 22 129 0 22 in the chinese PC I get 63 63 63 0 0 I also tried changing the regional settings in the PC to English but that did not work either.
-
AscB no good either. Thanks.
-
Thanks for your reply. The code reads data (not text) from eeprom in the instrument. The FTDI driver (which I have no control over) returns each byte read from the USB bus as a string character. That is why I use Asc(string) to get me the byte value that I need. The problem, for example: instead of reading 0 22 129 0 22 in the chinese PC I get 63 63 63 0 0 Thanks again
-
Thanks for your reply. The code reads data (not text) from eeprom in the instrument. The FTDI driver (which I have no control over) returns each byte read from the USB bus as a string character. That is why I use Asc(string) to get me the byte value that I need. The problem, for example: instead of reading 0 22 129 0 22 in the chinese PC I get 63 63 63 0 0 Thanks again
If you're reading data, net text, why are you using ASC() at all? That gets the ASCII value of a character, not a byte.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak -
Hello I am working with a piece of VB6 code that reads data from an instrument through the USB port. The instrument uses an FTID USB chip and the data is read by the host byte by byte from the USB bus using a driver supplied by FTID. Each data byte is returned as a string character and then converted using the function Asc(string). The problem is that on Windows 10 machines running chinese, the data returned is corrupted. I think this may have something to do with the longer (2 bytes per character instead of one) character coding used for chinese but I have not been able to understand the issue. Any suggestions?
May I ask why you don't read the data as Byte-Array instead of reading/converting them into a string ?
-
May I ask why you don't read the data as Byte-Array instead of reading/converting them into a string ?
Yes, the reason is that I am using the FTDI DXXX library to read data from the USB chip. This passes the data as a string.
-
That makes no sense, you cannot read 0 as 63 without some fairly bad code. You need to capture each character as it arrives and display it as a numeric value.
Well, the code could not be simpler. Just one line of code. The rest is done by the FTDI library routine that reads the USB data and passes it as a string. It all works fine in all systems we tested except Win10 running the chinese version. But thank you for taking the time to comment.
-
Yes, the reason is that I am using the FTDI DXXX library to read data from the USB chip. This passes the data as a string.
You should write something more about what you definately want to do. In the Moment I don't understand why you do it in that way ...
-
You should write something more about what you definately want to do. In the Moment I don't understand why you do it in that way ...
Well, it is quite simple and I did explain it before but let me try again. We have an instrument connected to the host PC. The software running on the PC needs to read EEPROM data held in the instrument. It sends a command to the instrument and the instrument responds by the sending the data. The software uses the FTDI DXXX library to read and write to the USB. The data is read byte by byte. The FTDI routine returns the data as a string. The software uses the Asc() function to get the value of each byte. It all works fine except in Win10 running the chinese version.
-
Well, it is quite simple and I did explain it before but let me try again. We have an instrument connected to the host PC. The software running on the PC needs to read EEPROM data held in the instrument. It sends a command to the instrument and the instrument responds by the sending the data. The software uses the FTDI DXXX library to read and write to the USB. The data is read byte by byte. The FTDI routine returns the data as a string. The software uses the Asc() function to get the value of each byte. It all works fine except in Win10 running the chinese version.
Of course ... I have read all you have written before. The thing what isn't clear for me is : why don't you read the data by the emulated COM-Port from the FTDI-Device ? I have had the same problem when I wanted to read the data from a RFID-Reader (and I solved it in that way).
-
Hello I am working with a piece of VB6 code that reads data from an instrument through the USB port. The instrument uses an FTID USB chip and the data is read by the host byte by byte from the USB bus using a driver supplied by FTID. Each data byte is returned as a string character and then converted using the function Asc(string). The problem is that on Windows 10 machines running chinese, the data returned is corrupted. I think this may have something to do with the longer (2 bytes per character instead of one) character coding used for chinese but I have not been able to understand the issue. Any suggestions?
-
Try using ASCW in stead of just plain ASC. ASC would be more for standard ASCII chars. Asc, AscW Functions[^]
-
Just curious why my answer got down voted when it was the first one and contained the information most other answers ?? -16 points not that I really care about points after all of these years here. Just Curious Why.
ledtech3 wrote:
it was the first one
You do realise we can see the dates when the messages were posted, right? :doh: Your answer was posted on 27th October at 3:45. And it's exactly the same suggestion and link as my answer[^], which was posted 25th October at 17:22 - more than a day earlier than yours.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
ledtech3 wrote:
it was the first one
You do realise we can see the dates when the messages were posted, right? :doh: Your answer was posted on 27th October at 3:45. And it's exactly the same suggestion and link as my answer[^], which was posted 25th October at 17:22 - more than a day earlier than yours.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Yeah but when I posted originally there were no other comments or questions showing up at the time. That's the reason I said that. Otherwise I would not have posted anything. I went thru the link from the email notification of the question so not sure if that was the reason or not that nothing else showed up. Either way I give up trying to "Help People" because of so many "Trolls" here.
-
Yeah but when I posted originally there were no other comments or questions showing up at the time. That's the reason I said that. Otherwise I would not have posted anything. I went thru the link from the email notification of the question so not sure if that was the reason or not that nothing else showed up. Either way I give up trying to "Help People" because of so many "Trolls" here.
There were answers showing up in the forum more than 24 hours before you posted your answer. If you couldn't see them, then you need to report that as a bug: Bugs and Suggestions[^] You posted an answer that had already been posted more than a day previously, when the OP had already indicated that the answer did not help. It's hardly "trolling" for someone to down-vote your answer. :doh:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
There were answers showing up in the forum more than 24 hours before you posted your answer. If you couldn't see them, then you need to report that as a bug: Bugs and Suggestions[^] You posted an answer that had already been posted more than a day previously, when the OP had already indicated that the answer did not help. It's hardly "trolling" for someone to down-vote your answer. :doh:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer