If you are interested in developing Console applications, keep in mind that all Console Input/Output in Delphi still is and will remain based on Ansi. This is true for routines like Read, Write, ReadLn, and WriteLn, among others. The console window displays characters using an ANSI codepage (or even an OEM codepage), and the same operations, when redirected to files, might cause the same problem.
Truly, the Windows Console can be opened in Unicode mode (by running it with the /u flag: cmd /u), but this is rarely done as it works only if your output is send to a file and not to the screen. Delphi 2009 doesn't support the Unicode mode of the console.
If you want to make some experiments you can start with the UnicodeCon-soleTest demo, in which I use a TTextWriter object60 with a Unicode encoding, connected with a stream associated with the standard output. Display to the console screen is incorrect, as expected. Redirecting to a file produces a UTF-16 file, but one without the BOM. This is the code: var aString: string; textWriter1: TTextWriter; fileStream1: TFileStream;
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.