I've run into a curious problem. I need to generate a UCS-2 encoded file. UCS-2 is a deprecated version of UTF-16 that is strictly 2-bytes per character. This means it cannot represent every Unicode character. Xojo does not have built-in support for UCS-2, so ConvertEncoding isn't an option.
So my goal is to remove or replace 4-byte characters before (or after) ConvertEncoding so that what is produced is valid UCS-2. That's proving to be difficult with String. Text handles this better, but Text isn't an option in this case because I could be dealing with megabytes of text and Text on Windows is slower than atoms at absolute zero.
Using RegEx hasn't worked because it can't work with multibyte strings. Looping over each character with Mid reads the 4-byte characters as 2 2-byte characters.
Anybody have any fast ideas?