Fixed another bug, something interesting, and a possible new feature
Working with Transformer in my workshop today, I discovered that the JavaScript engine, which does some automatic code-checking and gives you an error message when your JS code is wrong, was giving me an error message in garbled Chinese. This was doubly confusing because I was actually working on Chinese texts at the time. It turns out that the JavaScript Bridge code I'm using, which was written well before Delphi 2009 was on the horizon, has lots of PChars in its code. In D2009, a PChar is a PWideChar, but the text is actually not a WideString, it's just a plain Ansi string. Rather than hack the JS Bridge code, which is a bit fragile and unmaintained, I just cast the "PChar" return from the JS engine to a PChar and then to a string: string(PAnsiChar(message))
. This seems to do the job. The error messages will always be in English anyway.
I also discovered today that my "is it UTF-8?" detection code gives a false positive on GB18030 files (PRC Chinese encoding). This is annoying, but there's not much I can do about it. It just means that when opening such files in Transformer, it always suggests UTF-8 instead of GB18030.
Since I now have robust text file encoding conversion available, I think it would make sense to make this a batchable feature. I'll need to think about how best to do that, but it could be a part of the main batch screen, where you could specify the input encoding. There should be a new, initial tab entitled "Loading files", which should have a drop-down where you can specify the input encoding. You could discover this using the normal file-loading capabilities in the Source tab.