Avatar of ChrisMDrew

asked on 

Ensure CString has no non-printing characters before write to XML


I have a program which is recovering various bits of information about files and folders by reading the VERSIONINFO using GetFileVersionInfo.  While this works in the main, occasionally the string returned has non-printing characters as its last digit - most often 0x1 and 0x3.  After scanning many thousands of files I found 3 which had corrupt strings.

My problem is that I am writing this data to an XML file which becomes invalid with these non-printing characters.

What I would like is a method by which I can remove these non-printing characters and/or format the string so that it will always be valid within an XML file.

The CString::Trim functions don't seem to catch this and I have not been able to find an alternate method of doing this efficiently.  Any suggestions?
Editors IDEs

Avatar of undefined
Last Comment

8/22/2022 - Mon