Forum > Windows

CRT won't show ascii characters properly

(1/3) > >>

ShadowG04:
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  [+][-]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, 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:
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:
The American Standards Association "X3.4-1963 - American Standard Code for Information Interchange" (ASCII) source document: https://web.archive.org/web/20150901201534/https://worldpowersystems.com/projects/codes/X3.4-1963/

The only source of ASCII truth.

ShadowG04:

--- Quote from: Bart on January 28, 2021, 10:15:46 pm ---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

--- End quote ---

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 me
--- Quote ---http://www.productionautomation.net/FPC/ASCII/
--- End quote ---
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:

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

Navigation

[0] Message Index

[#] Next page

Go to full version