CRT won't show ascii characters properly lazarus / 67-Windows ---------------------------------------------------------------------- ShadowG04 · 2021-01-28 20:52 So im trying to use box characters for my program, but since im using CRT the characters won't display in the correct codepage. it appears that my system is using codepage 1252 but i did some research and i think that changing the codepage of the system on the regedit would mess up with my pc. im testing my output using this 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 CodePage; USES CRT; BEGIN        Writeln('Console output codepage: ', GetTextCodePage(Output));        Writeln('System codepage: ', DefaultSystemCodePage);        System.SetTextCodePage(Output, 850);      Writeln('Console output codepage: ', GetTextCodePage(Output));      Writeln('System codepage: ', DefaultSystemCodePage);        WriteLN (char(186)); {║}        WriteLN (char(167)); {º}        WriteLN (char(245)); {§}        WriteLN (char(229)); {Õ}        WriteLN (char(134)); {å}        ReadLn();END.  any ideas of what i could do to fix the output? ---------------------------------------------------------------------- Bart · 2021-01-28 21:15 Characters above #127 are not ASCII. Try setting the codepage of the console before running the program ("chcp 437", I think it is, without the quotes of course). Bart ---------------------------------------------------------------------- trev · 2021-01-28 22:10 The American Standards Association "X3.4-1963 - American Standard Code for Information Interchange" (ASCII) source document: https://web.arch ive.org/web/20150901201534/https://worldpowersystems.com/projects/code s/X3.4-1963/ The only source of ASCII truth. ---------------------------------------------------------------------- ShadowG04 · 2021-01-29 06:45 Quote from: Bart on January 28, 2021, 10:15:46 pmCharacters above #127 are not ASCII. Try setting the codepage of the console before running the program ("chcp 437", I think it is, without the quotes of course). Bart I changed the codepage from the console to all of the posible values and i still cant get box characters show up. I found a page with this guy having the same problem as meQuotehttp://www.productionautomation.net/FPC/ASCII/ it appears is all because crt doesnt show properly those characters. Looks like my options are either stop using crt or stop trying to use box characters on pascal ---------------------------------------------------------------------- lucamar · 2021-01-29 07:23 Quote from: ShadowG04 on January 29, 2021, 07:45:05 amI found a page with this guy having the same problem as meQuotehttp://www.productionautomation.net/FPC/ASCII/ it appears is all because crt doesnt show properly those characters. It's not because crt but because the console itself can't show those characters, most probably due to either the font used or because the code-page can not be properly changed to IBM437 (the only one which has all box characters). Also FP might be making an internal conversion between the system and console codepages before the output which might be mangling it all, though I'm not entirely sure that's true... In that page you cite the author forgot to make a simple test: compile and run his FP program under the same emulator (DOSBox) he did  the Turbo Pascal one: the result would demostrate the point that it's not really crt who's the culprit, I think. You can make another simple test: use CP437 for the console and try with a full-screen rather than a windowed one. And, BTW, don't test from inside the IDE: open a console and launch the program. ---------------------------------------------------------------------- FlierMate · 2021-01-29 08:24 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 CodePage; {USES CRT;} BEGIN        Writeln('Console output codepage: ', GetTextCodePage(Output));        Writeln('System codepage: ', DefaultSystemCodePage);        System.SetTextCodePage(Output, 65001);        Writeln('Console output codepage: ', GetTextCodePage(Output));      Writeln('System codepage: ', DefaultSystemCodePage);        WriteLN (widechar(#$250C)); {║}        WriteLN (widechar(#$2510)); {º}        WriteLN (widechar(#$2514)); {§}        WriteLN (widechar(#$2518)); {Õ}        WriteLN (widechar(#$252C)); {å}        ReadLn();END.  I try to use Unicode character and set the code page to 65001. Then it works fine on my PC. Not sure if this is the right way to do it. ---------------------------------------------------------------------- ASerge · 2021-01-29 14:26 Quote from: FlierMate on January 29, 2021, 09:24:54 amI try to use Unicode character and set the code page to 65001. Then it works fine on my PC. This work fine on my PC without chcp and SetTextCodePage: 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 {$APPTYPE CONSOLE}begin  Writeln(#$250C#$252C#$2510);  Writeln(#$2514#$2534#$2518);  Readln;end. ---------------------------------------------------------------------- FlierMate · 2021-01-29 14:32 Quote from: ASerge on January 29, 2021, 03:26:31 pmQuote from: FlierMate on January 29, 2021, 09:24:54 amI try to use Unicode character and set the code page to 65001. Then it works fine on my PC. This work fine on my PC without chcp and SetTextCodePage: 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 {$APPTYPE CONSOLE}begin  Writeln(#$250C#$252C#$2510);  Writeln(#$2514#$2534#$2518);  Readln;end. 👍 Fantastic! ---------------------------------------------------------------------- ShadowG04 · 2021-01-29 18:22 Quote from: FlierMate on January 29, 2021, 09:24:54 amCode: 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 CodePage; {USES CRT;} BEGIN        Writeln('Console output codepage: ', GetTextCodePage(Output));        Writeln('System codepage: ', DefaultSystemCodePage);        System.SetTextCodePage(Output, 65001);        Writeln('Console output codepage: ', GetTextCodePage(Output));      Writeln('System codepage: ', DefaultSystemCodePage);        WriteLN (widechar(#$250C)); {║}        WriteLN (widechar(#$2510)); {º}        WriteLN (widechar(#$2514)); {§}        WriteLN (widechar(#$2518)); {Õ}        WriteLN (widechar(#$252C)); {å}        ReadLn();END.  I try to use Unicode character and set the code page to 65001. Then it works fine on my PC. Not sure if this is the right way to do it. You're not using crt, thats why it works fine. ---------------------------------------------------------------------- ShadowG04 · 2021-01-29 18:25 Quote from: lucamar on January 29, 2021, 08:23:22 amQuote from: ShadowG04 on January 29, 2021, 07:45:05 amI found a page with this guy having the same problem as meQuotehttp://www.productionautomation.net/FPC/ASCII/ it appears is all because crt doesnt show properly those characters. It's not because crt but because the console itself can't show those characters, most probably due to either the font used or because the code-page can not be properly changed to IBM437 (the only one which has all box characters). Also FP might be making an internal conversion between the system and console codepages before the output which might be mangling it all, though I'm not entirely sure that's true... In that page you cite the author forgot to make a simple test: compile and run his FP program under the same emulator (DOSBox) he did  the Turbo Pascal one: the result would demostrate the point that it's not really crt who's the culprit, I think. You can make another simple test: use CP437 for the console and try with a full-screen rather than a windowed one. And, BTW, don't test from inside the IDE: open a console and launch the program. Did the test and nothing changed, i'll run some test with DOSBox emulator to see if thats the problem. ---------------------------------------------------------------------- FlierMate · 2021-01-29 19:47 Windows Console is using UCS, and hence while Unicode 0~127 can represent ASCII(0x0 ~0x7F), 128~255 (and beyond) cannot. Finally I understand why, the widely adopted UTF-8 is a variable-width encoding. Extended ASCII 128 and above are used by UTF-8, either as continuation byte (128-191), or as indicator of the width of encoded bytes (0xCx, 0xEx, 0xFx). It means that if extended ASCII is still in use, Unicode (or UCS) has no way to differentiate which is Unicode character and which is not. After all, each byte has only 8-bit.