Forum > Windows

Unit CRT changes the ASCII character set

(1/2) > >>

Vampirro:
Hi,

This is my first post and I'm sorry about my poor English.

Well, I have to make an old fashioned DOS application for Windows, with the ▒╣ and similar characters to create windows. But when I use the CRT unit for using colours, gotoxy and so on the character set changes to CP-1252. I've tried to print all the ASCII character set but these characters (▒╣╩╦) have gone. I've tried to use UTF-8 with


--- 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";}};} ---write (utf8ToAnsi('░'));
But the result is the character '¦' (the same with ▒,▓...)

How can I resolve this problem? Thanks for all

Vampirro:
I don't know if it's important, but... I have Windows 10. 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 ascii; begin    writeln(chr(176));end. 
prints "░" in screen, but this one:


--- 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 ascii; uses crt; begin    writeln(chr(176));end. 
prints this character "°". Why? How can I continue using the "non-CRT" characters with the crt functions and procedures?

marcov:
Windows has three character encodings:

- Unicode, which is UTF16 for unicode characters
- ansi, which is a collective name for various 8-bit encodings (including utf-8 in the few places where Windows uses it)
- oem, the dos-like codepage from the console.

Constants are ansi, but you want to print OEM. The conversion function is ansitooem (which is nowadays implemented using chartooem). CRT takes over the console and probably does this automatically (?)

Another thing to try is changing the OEM codepage from the default 850 to ancient default dos with

chcp 437

before running your program.

Vampirro:
Thanks!

But... I'm not used to code in Pascal. I'm looking for an example of CharToOemBuff function in a Free Pascal program but I cannot find it. Could you give me an example, please?

Thanks for all

jackokring:
https://bitbucket.org/jackokring/clifly-fpc/src/master/ Not all of it, as it is far from complete U437 does translations from ANSI code page and cp437 into UTF-8 encoded AnsiStrings. If your terminal is UTF-8 compatible, then this should print correct. It seems the console appears to switch into ISO latin-1, which indicates potential Unicode compatibility? I've tried the source, but the code page mentioned in crt, video ... confusion.

Navigation

[0] Message Index

[#] Next page

Go to full version