Console Application lazarus / 34-Windows ---------------------------------------------------------------------- jcmontherock · 2021-12-29 16:21 For a console application under W11/64 UTF-8 encoded with Laz 220RC2. Is somebody knows how to display accented characters with Writeln or something else ? ---------------------------------------------------------------------- Bart · 2021-12-29 16:36 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   SetTextCodePage(Output, CP_UTF8);  SetConsoleOutputCP(CP_UTF8); Bart ---------------------------------------------------------------------- jcmontherock · 2021-12-29 17:16 Thanks, but how do you assign Text in SetTextCodePage ? ---------------------------------------------------------------------- jwdietrich · 2021-12-29 18:53 Quote from: jcmontherock on December 29, 2021, 06:16:53 pmThanks, but how do you assign Text in SetTextCodePage ? Bart's code should be sufficient. SetTextCodePage sets the code page for a file that is passed by reference as the first parameter. Here, it is the virtual file "Output", i.e. the standard output to the terminal window. So, subsequent calls to write or writeln should use the specified code page. ---------------------------------------------------------------------- jcmontherock · 2021-12-30 10:12 Finally, I found what it happen: it's coming from the unit Crt.pp. I did not found the error, in that unit. I cannot do the test it with a non-utf-8 windows version. Could somebody do it, to check that's is the same ? small test: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program tstConsole;{$mode objfpc}{$H+}{$APPTYPE CONSOLE}// {$CODEPAGE UTF-8}uses  Classes, SysUtils, LConvEncoding  //, Crt  // <===  uncomment this line, then it will not work  ;var  txt: String;begin  //SetConsoleOutputCP(CP_UTF8);  txt := 'éééééééàààààààà  ©';  Writeln(txt);  //txt := AnsiToUtf8('éà  ©');  //Writeln(txt);end. ---------------------------------------------------------------------- Fred vS · 2021-12-30 13:49 Hello. If you want to access keyboard on console application, you may have more luck using "keyboard" unit vs "crt" unit. See here: https://forum.lazarus.freepascal.org/index.php/topic,57284.m sg426272.html#msg426272 [EDIT] Of course, you should adapt (or remove) the const CHARS with your desire. Fre;D ---------------------------------------------------------------------- jcmontherock · 2021-12-30 15:26 Thanks a lot.  It solves my problem with Crt.pp. ---------------------------------------------------------------------- Bart · 2021-12-30 16:33 Quote from: jcmontherock on December 30, 2021, 11:12:50 amFinally, I found what it happen: it's coming from the unit Crt.pp. I did not found the error, in that unit. Crt unit has 2 procedures that influence what it does when it writes to console (by default it will reset the consoles codepage on each write to the default value): SetSafeCPSwitching() and  SetUseACP(), both procedures take a boolean as their parameter. Just play around with these 2 (only 4 possible combinations, I'm too lazy to test). Bart