03-26-2018 08:47 AM
I have an app that parses an XML file generated by .NET with the CVIXML library. The contents of that XML file have 2 bytes per character, and under normal situations the contents fit within the plain ASCII set, so every character only needs one byte, and can be represented within char[] in CVI.
I have been pleased to see that the CVIXML library (or underlying MS DLL?) handles the 2-byte to 1-byte transition in parsing, but issues arise when the XML file contains characters that use 2 bytes. Here is a hex view of such a case in the file with a 2-byte character (Greek alpha):
There seems to be a best-effort attempt to find and correct this 2 byte to 1 byte transition for non-ASCII characters, but it is not always possible. Specifically:
The most problematic aspect of this is that we will lose uniqueness of the output values with all unsupported characters mapping to '?'.
The CVIXMLGetAttributeValue function returns 0 (success) in all these cases.
So my question is: Is there any way within the library to detect cases where the the XML file contains unsupported 2-byte characters? Or would I need to separately parse that input file and look at it byte-by-byte?
03-27-2018 09:47 AM
Hi Ian,
From my research, there does not seem to be any functionality in library which can handle greek characters in the way that you have mentioned. There may be a C function call (not specific to the CVIXML library) which can handle it but I'm not too sure of that. The best course of action will most likely be to separately parse the file and look like it byte by byte as you have mentioned.
Also, out of curiousity, what version of LabWindows/CVI are you using?
04-13-2018 12:18 PM
SaileshK, thanks for the investigation and the reply. I had feared that. This old application is still on the old compiler (~2010). Would you expect the result to be different with the latest version of CVI?
04-16-2018 10:14 AM
Ian,
Unfortunately I haven't found any evidence that a newer version of LabWindows/CVI would result in a different outcome (no changelogs mention anything about the behavior you are seeing). However, if you attach your source code, I can try and see if a different result than what you are getting occurs!