Can't print a character a number of time equals to the terminal's width lazarus / 21-General ---------------------------------------------------------------------- throwaway34865 · 2021-02-06 12:23 So I have a simple Pascal code which prints the character "■" a number of time that is equal to the terminal's width on Windows 7 using Free Pascal version 3.2.0:  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 uses crt;var i:Integer;begin clrscr; for i:=1 to WindMaxX do  write('■');end.It should output a long stream of the character "■" like this: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■H owever, what I got from running the code was different: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ■■■■■■■■■■■■■■■■■■■■■■■■■■��                                                                                                  �■■■■■■■■■■■■■■■■■■■■■■■■■■�                                                                                                  ��■■■■■■■■■■■■■■■■■■■■■■■■■■Do anyone know why it isn't returning the right output? I really appreciate all the help. ---------------------------------------------------------------------- dseligo · 2021-02-06 12:47 I just tried your code and it works fine (FPC 3.2.0, Windows 10). Try this and post results: 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 test_ispis;uses crt,sysutils;var i:Integer;begin  clrscr;  WriteLn(inttostr(Windmaxx));  for i:=1 to WindMaxX-1 do    write(chr(i mod 10 + 48));  Write('x');end. ---------------------------------------------------------------------- Kays · 2021-02-06 19:44 Quote from: throwaway34865 on February 06, 2021, 01:23:52 pm[…] the character "■" […]The problem is '■' is not a character, but a string, encoded as a UTF-8 stream it’s three Bytes E2 96 A0. The first page of CRT’s documentation states (last bullet point): “The CRT unit […] is designed to work with single-byte character sets, where 1 char = 1 byte. That means […] UTF-8 encoded (ansi)strings will not work correctly.” That is why you suddenly find yourself with three lines, instead of just one. You must either use a different character, or—highly recommended—use a more modern library such as nCurses. There is nCRT that serves as an (almost) drop-in replacement for CRT. Here’s the nCurses solution: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 block(input, output, stdErr);{$modeSwitch exceptions+}uses        nCurses, cWString;var        i: integer;begin        try                initScr();                                for i := 1 to getMaxX(stdScr) do                begin                      addStr('■');                end;                                getCh();        finally                endWin();        end;end.