Forum > General

Extended ASCII use - 2

<< < (3/10) > >>

SymbolicFrank:



C̵̢̦̖̭̯̮̦̼̺̮̮̺̳̹̰̤̆̿̈́̓͆̄͌̉̂̏̑̌͋͝ŗ̴̡̻̫̻͖͍̙̥̬͔̩̖̰̱̈̌́̈́̀͛͋͌̈́͂̿̃͊̿͑̀̚à̴̢̦͓͕͍̘̰̯͔͕̈́͋̈̃̀̒̐͛͜ͅz̸̢̧̛̦̘̥̥̩͓͍̖͇͔͍̦͚̤͒̐̅̄͊͋̍͑́͒̅̎͝͝ỳ̸̨̫̳̤͕̬͈̹̭̜̠̻̹̅ ̵̢̨̧͉̥̹̜͔̬̬̞́̽̉̓̇̅̾͝ŝ̸͔̲̹̄̚ͅt̸̡̯͎̳̩̪͍͈̔̍̈́͘͜ũ̶̞͕̠̺̈́́̌͑̐̿̔̌͒͋̋͌̕͠f̸̡͚̀̐̉̾̋̑̕͠͠f̷̛̩͔̰̄̊͗̋͗̆̅̌͒̄̒͐͛͐͝,̸̢̮͙̜̬͍̱͈͙̟̳̬̑͗̾́̋̄̈́͜ͅ ̸̟͈͎̘͕̙̺͖̙̝̺̬͑ȩ̷̧̢͉͍͖͚̗̻̳͎̽͛͗̀̽͂͌̅͌͊̈̈̋̈́͘͘̚h̵͖̘͇̦̞̪̓̈̈́̄̆͗̅̆̓̿̒̄̂͋̓̚?̷̟̪͍̜̳̹͖̯͊̏̑͠͝



16 chars, 676 bytes.

JuhaManninen:
@raymond, I suggest you forget IBM 850 and all other 'Extended ASCII' codepages. They lead to all kinds of agony when data is exchanged.
Just convert your data to Unicode. It has solved such problems already decades ago.

[Edit] Crazy stuff, eh?
Try to do that with Extended ASCII codepages!

engkin:
@raymond,


--- Quote from: raymond on January 11, 2022, 02:52:51 pm ---My interest is in using fpc without Lazarus, as was possible with fpc and FreeDOS and code set IBM 850, which covers all the 'European' characters.

--- End quote ---

1-Make sure to tell the compiler the codepage/encoding you use in your source code. For instance, if a file is using the same codepage you want, IBM 850, then add this to the top of file:

--- 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 project1; {$mode objfpc}{$H+}{$Codepage cp850}//<--- Tell the compiler about the codepage used in this file uses
2-Make sure your dos is using the same codepage by calling chcp

What output do you get for this test project:

--- 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 project1; {$mode objfpc}{$H+}{$Codepage cp850} var  s:array[0..3] of String;  ss:string;  i:byte;  c:char;begin  WriteLn('DefaultSystemCodePage: ',DefaultSystemCodePage);  WriteLn('TextRec(Output).CodePage: ',TextRec(Output).CodePage);  ss:='ÄÇýÝ';  WriteLn(ss);   //CP850: #$80..#$FF  s[0]:='ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃';  s[1]:='áíóúñѪº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐';  s[2]:='└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀';  s[3]:='ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■';  for i:=$80 to $FF do  begin    if (i mod 32)=0 then    begin      WriteLn();      WriteLn();      WriteLn(s[i div 32 - 4]);    end;    if i in [$07,$08,$09,$0A,$0D] then      c:=' '    else      c:=char(i);    Write(c);  end;end.

tetrastes:

--- 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";}};} ---  for i:=$80 to $FF do  begin    if (i mod 32)=0 then    begin      WriteLn();      WriteLn();      WriteLn(s[i div 32 - 4]);    end;    if i in [$07,$08,$09,$0A,$0D] then      c:=' '    else      c:=char(i);   // ! This is invalid in utf8 and leads to runtime error 101    Write(c);  end; 

Thaddy:
Note that if you do not use Lazarus (As you stated) but only FPC, you can use {$mode delphiunicode} and char would be unicodechar. But that is by no means single byte, mostly double byte (the ucs2 part) and possibly  - again - 4 bytes.
This mode will make your life easier, though.
This example covers technically UCS2, but that is an ancestor to current unicode16 and a 4 byte unicodechar is not implemented as such:
--- 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 size;{$mode delphiunicode}begin  writeln(SizeOf(Char));end.In an ideal world it should return 4, imho.  >:(
OTOH this was defined before the unicode extensions in the standard and fpc can handle the 4 case as well. Just like Delphi.
That does mean you still have to reserve 4 bytes per UnicodeChar, not two as per my example.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version