Forum > General

Extended ASCII use - 2

<< < (4/10) > >>

engkin:

--- Quote from: tetrastes on January 11, 2022, 08:48:48 pm ---
--- 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";}};} ---      c:=char(i);   // ! This is invalid in utf8 and leads to runtime error 101 
--- End quote ---

What would be the correct way considering:

--- 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";}};} ---{$mode objfpc}{$H+}{$Codepage cp850} var..  i:byte;  c:char;

tetrastes:

--- Quote from: Thaddy on January 11, 2022, 09:01:35 pm ---In an ideal world it should return 4, imho.  >:(

--- End quote ---
By the way, at linux

--- Code: C  [+][-]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";}};} ---sizeof(wchar_t)returns 4.  :-X

Thaddy:
Yes.

tetrastes:
@engkin
To imitate CP850 at UTF8 console without errors:

--- 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} {$IFDEF UNIX}uses cwstring;    // We need properly working UnicodeManager, of course{$ENDIF} type  CP850String = type AnsiString(850); 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(CP850String(c));    // SIC!  end;end. 

SymbolicFrank:

--- Quote from: Thaddy on January 11, 2022, 09:01:35 pm ---In an ideal world it should return 4, imho.  >:(

--- End quote ---
Totally agree. Go Linux!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version