Forum > Windows

CRT won't show ascii characters properly

<< < (2/3) > >>

FlierMate:

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

--- Quote from: FlierMate on January 29, 2021, 09:24:54 am ---I try to use Unicode character and set the code page to 65001. Then it works fine on my PC.

--- End quote ---
This work fine on my PC without chcp and SetTextCodePage:

--- 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";}};} ---{$APPTYPE CONSOLE}begin  Writeln(#$250C#$252C#$2510);  Writeln(#$2514#$2534#$2518);  Readln;end.

FlierMate:

--- Quote from: ASerge on January 29, 2021, 03:26:31 pm ---
--- Quote from: FlierMate on January 29, 2021, 09:24:54 am ---I try to use Unicode character and set the code page to 65001. Then it works fine on my PC.

--- End quote ---
This work fine on my PC without chcp and SetTextCodePage:

--- 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";}};} ---{$APPTYPE CONSOLE}begin  Writeln(#$250C#$252C#$2510);  Writeln(#$2514#$2534#$2518);  Readln;end.
--- End quote ---

👍 Fantastic!

ShadowG04:

--- Quote from: FlierMate on January 29, 2021, 09:24:54 am ---
--- 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 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.

--- End quote ---

You're not using crt, thats why it works fine.

ShadowG04:

--- Quote from: lucamar on January 29, 2021, 08:23:22 am ---
--- Quote from: ShadowG04 on January 29, 2021, 07:45:05 am ---I found a page with this guy having the same problem as me
--- Quote ---http://www.productionautomation.net/FPC/ASCII/
--- End quote ---
it appears is all because crt doesnt show properly those characters.
--- End quote ---

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.

--- End quote ---

Did the test and nothing changed, i'll run some test with DOSBox emulator to see if thats the problem.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version