You may find the "SetTextCodePage" procedure useful when it comes to setting the code page for a Windows console.

e.g. SetTextCodePage(stdout,cp_utf8);

See also https://www.freepascal.org/docs-html/rtl/system/settextcodepage.html


On 22/02/18 11:21, Luca Olivetti via Lazarus wrote:
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

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to