[Lazarus] Garbage writing to console

Luca Olivetti luca at wetron.es
Thu Feb 22 12:21:57 CET 2018


Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
application unchecked") or console application (using LazUTF8).
File encoding utf-8 without bom.

writeln('áéí')

produces garbage, contrary to what's said in 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console

using {$codepage utf8} (or utf-8 with bom) fixes it, but I'm not sure 
it's recommended to do so: 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#String_Literals

The strange thing is that:

procedure w(const s:string);
begin
   writeln(s);
end;

w('áéí')


also gives the correct output.
Why? After all I'm using the same string literal.
I suppose there's some underlying automatic conversion going on, but 
it's very confusing.

Bye
-- 
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007


More information about the Lazarus mailing list