I'm using some PInvoke calls (specifically GetWindowText()
) and occasionally I get a string with invalid Unicode code points in it (probably due to bugs in the program whose window I'm looking at). When I later try to write that string to XML, I get an exception. So I'd like to check for these invalid characters beforehand and, if possible, remove them from the string.
Unfortunately I cannot find anything in .NET's default functions that would allow me to do that. Did I miss something?