Forum > Windows

Console Application

(1/2) > >>

jcmontherock:
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:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  SetTextCodePage(Output, CP_UTF8);  SetConsoleOutputCP(CP_UTF8);
Bart

jcmontherock:
Thanks, but how do you assign Text in SetTextCodePage ?

jwdietrich:

--- Quote from: jcmontherock on December 29, 2021, 06:16:53 pm ---Thanks, but how do you assign Text in SetTextCodePage ?

--- End quote ---

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:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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. 

Navigation

[0] Message Index

[#] Next page

Go to full version