Writeln followed by _WriteWChar prints a question mark

45 views Asked by At

In our legacy application we have lots of code similar to this:

Writeln('Line 1');
Write('Line 2:', '_': 5);

Under D2007 this outputs

Line 1
Line 2:    _

as expected. Under XE6 I get

Line 1
Line 2:?    _

, please note the extraneous question mark in line 2. It ist explicitly added by _WriteWChar because t.UTF16Buffer[0] isn't empty. This in turn is because Writeln writes to t.MBCSBuffer[0] (which overlaps t.UTF16Buffer[0]) but doesn't clear it afterwards.

My test program:

program WriteSpaceTest;

{$APPTYPE CONSOLE}

begin
  Writeln('Line 1');
  //TTextRec(Output).UTF16Buffer[0] := #0;
  Write('Line 2:', '_': 5);
  Readln;
end.

The commented line is one workaround for XE6. I can also avoid using _WriteWChar by writing something like

  Write('Line 2:', '    _');

What I want to know: Is this a bug in XE6? If so, is it fixed in later versions? Any idea if my clear-UTF16Buffer-workaround screws something?

0

There are 0 answers