Convert special characters for tables in TurboPascal lazarus / 64-FPC development ---------------------------------------------------------------------- forbin · 2018-07-30 13:24 Hello, I've developed some Turbo Pascal DOS 7.0 using some characters displaying tables such as : ┐ ┴ ┬ ┼ I can't display any more the table since i convert my programs in Free Pascal. How can i do to convert these special characters ? Thanks 4BIN ---------------------------------------------------------------------- Handoko · 2018-07-30 13:51 Hello forbin, Welcome to the forum. Ah, that are extended ASCII characters. I used them a lot. https://theasciicode.com.ar/ I just tested this code below, it works correctly on Lazarus 1.8.4 Ubuntu 18.04: 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 project1; begin  WriteLn('┌───────┐');  WriteLn('│ HELLO │');  WriteLn('└───────┘');  ReadLn;end.              If you can't make it works, I think it is not Free Pascal / Lazarus issue. Can you show us your code? Or maybe this thread can be useful for you: https://forum.lazarus.freepascal.org/index.php/topic,41118.msg284772.h tml ---------------------------------------------------------------------- tr_escape · 2018-07-30 13:53 Generally I am using that chars: Courier New font in windows 7: ╔╚╝╠╣╦╩╬ You can access with by charmap.exe I didn't try in Linux desktop. Also you can copy + paste from the editor of charmap to your software as mentioned below: (Very simple and bad method) 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 unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; const borders='╔╚╝╠╣╦╩╬';  type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Memo1: TMemo;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  n:Integer;  str: UnicodeString;begin  Memo1.Lines.Clear;  Memo1.Lines.Add(borders);   Memo1.Lines.Add('');   str:='';  for n:= $2554 to $256c do    str+=UnicodeChar(n);   Memo1.Lines.Add(str);end; end. ---------------------------------------------------------------------- Handoko · 2018-07-30 14:05 tr_escape's code worked on my test on my Linux computer. The TMemo was using the system default font. ---------------------------------------------------------------------- Thaddy · 2018-07-30 16:15 It depends on the codepage you are using. Can you tell me what chcp tells you? (type chcp on the command prompt) ---------------------------------------------------------------------- forbin · 2018-08-10 07:20 Hi Friends, Thanks for your kind answers ! Unfortunatly i use the FP compiler which runs under MS-DOS. I display my program in the CMD.EXE's windows. The trouble happens in the CMD.EXE's windows. However one can display the table's characters through the CMD.EXE's windows. That means that the problem comes from the translation of the character by FPC. How to translate, that's the question  Thanks 4BIN ---------------------------------------------------------------------- Thaddy · 2018-08-10 07:51 Can you tell me what chcp does in cmd.exe? ---------------------------------------------------------------------- forbin · 2018-08-10 10:09 Hi, I've applied the following code 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 Project1;        {$MODE OBJFPC}    {$APPTYPE CONSOLE}     const       C = #17#16#30#31#207#177;         procedure Print;    var      ShortS: ShortString = C;      AnsiS: AnsiString = C;    begin      Writeln;    Writeln('ShortString = ', ShortS);      Writeln('AnsiString  = ', AnsiS);    end;         begin      Writeln('DefaultSystemCodePage = ', DefaultSystemCodePage);      Writeln('ConsoleCodePage       = ', TextRec(Output).CodePage);      Print;      SetMultiByteConversionCodePage(TextRec(Output).CodePage);      Writeln;      Writeln('DefaultSystemCodePage = ', DefaultSystemCodePage);      Print;      Readln;    end.   which you've provided. It has worked but when i tried this 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 TRYCHAR; {$MODE OBJFPC}{$APPTYPE CONSOLE} USES DOS, CRT, SYSUTILS; CONST  scne=#191;       scnw=#218;       scsw=#192;       scse=#217;       slho=#196;       slve=#179; BEGIN   SetMultiByteConversionCodePage(TextRec(Output).CodePage);  writeln('DefaultSystemCodePage = ', DefaultSystemCodePage);  Writeln('ConsoleCodePage       = ', TextRec(Output).CodePage);   writeln(scnw,slho,scne);  writeln(slve,' ',slve);  writeln(scsw,slho,scse); END.  it displayed the wrong characters and codepage 1252. However the mode is Statut du périphérique CON: ---------------------------     Lignes :          9001     Colonnes :        120     Vitesse clavier : 31     Délai clavier :   1     Page de codes :   850 I understand not why the mode doesn't remain in CP850. Thanks again for your help ! Best regards 4BIN ---------------------------------------------------------------------- forbin · 2018-08-10 10:27 It seems there is a conflict with CRT unit. When i remove CRT in the USES command it works, else not. I unfortunately need the CRT unit. How to reconciliate them ? ---------------------------------------------------------------------- Thaddy · 2018-08-10 11:29 The system code page is for your Windows GUI. The console codepage is what you need for crt. You can try SetConsoleOutputCP under windows os's to set the actual console codepage output ---------------------------------------------------------------------- forbin · 2018-08-10 12:02 Thanks but i dont know how to do it. is SetConsoleOutputCP a Free Pascal command or should i use regedit or something else ? ---------------------------------------------------------------------- Thaddy · 2018-08-10 14:31 Quote from: forbin on August 10, 2018, 02:02:44 pmThanks but i dont know how to do it. is SetConsoleOutputCP a Free Pascal command or should i use regedit or something else ? It is a function from the windows API and in winunits-base. Simply include windows in the uses clause.. Maybe this helps: http://forum.lazarus.freepascal.org/index.php/topic, 38910.msg265726.html#msg265726 ---------------------------------------------------------------------- forbin · 2018-08-11 16:04 Many Thanks Thaddy, I've tried 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 TRYCHAR; {$mode objfpc}{$H+}{$APPTYPE CONSOLE} USES {$IFDEF WINDOWS}   Windows, {for setconsoleoutputcp}     {$ENDIF} DOS, CRT; CONST  scne=#191;       scnw=#218;       scsw=#192;       scse=#217;       slho=#196;       slve=#179; VAR f1,f2:TEXT; BEGIN   {$IFDEF WINDOWS}  SetConsoleOutputCP(CP_UTF8);  {$ENDIF}   SetMultiByteConversionCodePage(TextRec(Output).CodePage);  writeln('DefaultSystemCodePage = ', DefaultSystemCodePage);  Writeln('ConsoleCodePage       = ', TextRec(Output).CodePage);   writeln(scnw,slho,scne);  writeln(slve,' ',slve);  writeln(scsw,slho,scse);   Assign(f2,'OUTPUT.DAT');  Rewrite(f2);    writeln(f2,scnw,slho,scne);    writeln(f2,slve,' ',slve);    writeln(f2,scsw,slho,scse);  Close(f2); END.  but here is the result DefaultSystemCodePage = 1252 ConsoleCodePage       = 1252 ÚÄ¿ ³ ³ ÀÄÙ what was wrong ---------------------------------------------------------------------- engkin · 2018-08-11 21:46 As you have seen, adding unit CRT is causing some issues. Unit CRT is changing the console code page to ANSI: 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   SetConsoleOutputCP(GetACP); If I change your code to: 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 TRYCHAR; {$mode objfpc}{$H+}{$APPTYPE CONSOLE} USES {$IFDEF WINDOWS}   Windows, {for setconsoleoutputcp}     {$ENDIF} DOS     , UnicodeCRT; CONST  scne='┐';//#191;  { use Unicode instead of ANSI }     scnw='┌';//#218;       scsw='└';//#192;       scse='┘';//#217;     slho='─';//#196;       slve='│';//#179; VAR f1,f2:TEXT; BEGIN  {$IFDEF WINDOWS}  SetConsoleOutputCP(CP_UTF8);  {$ENDIF}   SetMultiByteConversionCodePage(CP_UTF8);  TextRec(Output).CodePage := CP_UTF8;  writeln('DefaultSystemCodePage = ', DefaultSystemCodePage);  Writeln('ConsoleCodePage       = ', TextRec(Output).CodePage);   writeln(scnw,slho,scne);  writeln(slve,' ',slve);  writeln(scsw,slho,scse);   Assign(f2,'OUTPUT.DAT');  Rewrite(f2);    writeln(f2,scnw,slho,scne);    writeln(f2,slve,' ',slve);    writeln(f2,scsw,slho,scse);  Close(f2); END. and change unit CRT to support Unicode, as in the attached archive, it shows the characters right as in the attached image. Of course I had to choose a font for the console that supports Unicode. Edit: Unit UnicodeCRT is just a POC, it might not work properly.