Browse Source

* use FPC's integrated codepage conversion for non-Unicode unix consoles

git-svn-id: branches/unicodekvm@48923 -
nickysn 4 years ago
parent
commit
15ff16d852
3 changed files with 5 additions and 233 deletions
  1. 0 1
      .gitattributes
  2. 0 73
      packages/rtl-console/src/unix/convert.inc
  3. 5 159
      packages/rtl-console/src/unix/video.pp

+ 0 - 1
.gitattributes

@@ -8850,7 +8850,6 @@ packages/rtl-console/src/os2/crt.pp svneol=native#text/plain
 packages/rtl-console/src/os2commn/keyboard.pp svneol=native#text/plain
 packages/rtl-console/src/os2commn/keyboard.pp svneol=native#text/plain
 packages/rtl-console/src/os2commn/mouse.pp svneol=native#text/plain
 packages/rtl-console/src/os2commn/mouse.pp svneol=native#text/plain
 packages/rtl-console/src/os2commn/video.pp svneol=native#text/plain
 packages/rtl-console/src/os2commn/video.pp svneol=native#text/plain
-packages/rtl-console/src/unix/convert.inc svneol=native#text/plain
 packages/rtl-console/src/unix/crt.pp svneol=native#text/plain
 packages/rtl-console/src/unix/crt.pp svneol=native#text/plain
 packages/rtl-console/src/unix/keyboard.pp svneol=native#text/plain
 packages/rtl-console/src/unix/keyboard.pp svneol=native#text/plain
 packages/rtl-console/src/unix/mouse.pp svneol=native#text/plain
 packages/rtl-console/src/unix/mouse.pp svneol=native#text/plain

+ 0 - 73
packages/rtl-console/src/unix/convert.inc

@@ -1,73 +0,0 @@
-const convert_linuxlowascii_to_vga:array[#0..#31] of word=(
-        $0020,$0001,$0002,$0003,$0004,$0005,$0006,$0007,
-        $00db,$0009,$00db,$000b,$006f,$0070,$006e,$002a,
-        $0010,$0011,$0012,$0013,$0014,$0015,$0016,$0017,
-        $0018,$0019,$001a,$0011,$001c,$001d,$001e,$001f
-      );
-      convert_lowascii_to_iso01:array[#0..#31] of word=(
-        $0020,$006f,$006f,$006f,$006f,$006f,$006f,$0020, { $00..$07 }
-        $f861,$006f,$f861,$0064,$006f,$0070,$006e,$002a, { $08..$0f }
-        $003e,$003c,$007c,$0021,$00b6,$00a7,$005f,$007c, { $10..$18 }
-        $0076,$005e,$003e,$003c,$f86d,$f86e,$005e,$0076  { $18..$1f }
-      );
-      convert_cp437_to_iso01:array[#128..#255] of word=(
-        $00c7,$00fc,$00e9,$00e2,$00e4,$00e0,$00e5,$00e7, { $80..$87 }
-        $00ea,$00eb,$00e8,$00ef,$00ee,$00ec,$00c4,$00c5, { $88..$8f }
-        $00c9,$00e6,$00c6,$00f4,$00f6,$00f2,$00fb,$00f9, { $90..$97 }
-        $00ff,$00d6,$00dc,$00a2,$00a3,$00a5,$0050,$0066, { $98..$9f }
-        $00e1,$00ed,$00f3,$00fa,$00f1,$00d1,$00aa,$00ba, { $a0..$a7 }
-        $00bf,$f86c,$00ac,$00bd,$00bc,$00a1,$00ab,$00bb, { $a8..$af }
-        $f861,$f861,$f861,$f878,$f875,$f875,$f875,$f86b, { $b0..$b7 }
-        $f86b,$f875,$f878,$f86b,$f86a,$f86a,$f86a,$f86b, { $b8..$bf }
-        $f86d,$f876,$f877,$f874,$f871,$f86e,$f874,$f874, { $c0..$c7 }
-        $f86d,$f86c,$f876,$f877,$f874,$f871,$f86e,$f876, { $c8..$cf }
-        $f876,$f877,$f877,$f86d,$f86d,$f86c,$f86c,$f86e, { $d0..$d7 }
-        $f86e,$f86a,$f86c,$f861,$f861,$f861,$f861,$f861, { $d8..$df }
-        $0061,$00df,$f86c,$f87b,$0053,$0073,$00b5,$0054, { $e0..$e7 }
-        $00d8,$0054,$004f,$0064,$0049,$00f8,$0065,$006e, { $e8..$ef }
-        $003d,$00b1,$f879,$f87a,$f878,$f878,$00f7,$00b1, { $f0..$f7 }
-        $00b0,$0078,$00b7,$0056,$006e,$00b2,$002a,$00a0  { $f8..$ff }
-      );
-      convert_cp850_to_iso01:array[#128..#255] of word=(
-        $00c7,$00fc,$00e9,$00e2,$00e4,$00e0,$00e5,$00e7, { $80..$87 }
-        $00ea,$00eb,$00e8,$00ef,$00ee,$00ec,$00c4,$00c5, { $88..$8f }
-        $00c9,$00e6,$00c6,$00f4,$00f6,$00f2,$00fb,$00f9, { $90..$97 }
-        $00ff,$00d6,$00dc,$00a2,$00a3,$00a5,$0050,$0066, { $98..$9f }
-        $00e1,$00ed,$00f3,$00fa,$00f1,$00d1,$00aa,$00ba, { $a0..$a7 }
-        $00bf,$f86c,$00ac,$00bd,$00bc,$00a1,$00ab,$00bb, { $a8..$af }
-        $f861,$f861,$f861,$f878,$f875,$00c1,$00c2,$00c0, { $b0..$b7 }
-        $00a9,$f875,$f878,$f86b,$f86a,$00a2,$00a5,$f86b, { $b8..$bf }
-        $f86d,$f876,$f877,$f874,$f871,$f86e,$00e3,$00c3, { $c0..$c7 }
-        $f86d,$f86c,$f876,$f877,$f874,$f871,$f86e,$00a4, { $c8..$cf }
-        $00f0,$00d0,$00ca,$00cb,$00c8,$0069,$00cd,$00ce, { $d0..$d7 }
-        $00cf,$f86a,$f86c,$f861,$f861,$00a6,$00cc,$f861, { $d8..$df }
-        $00d3,$00df,$00d4,$00d2,$00f5,$00d5,$00b5,$00fe, { $e0..$e7 }
-        $00de,$00da,$00db,$00d9,$00fd,$00dd,$00af,$00b4, { $e8..$ef }
-        $00ad,$00b1,$f879,$00be,$00b6,$00a7,$00f7,$00b8, { $f0..$f7 }
-        $00b0,$00a8,$00b7,$00b9,$00b3,$00b2,$002a,$00a0  { $f8..$ff }
-      );
-      convert_lowascii_to_UTF8:array[#0..#31] of WideChar=(
-        #8199,#9786,#9787,#9829,#9830,#9827,#9824,#8226,
-        #9688,#9675,#9689,#9794,#9792,#9834,#9835,#9788,
-        #9658,#9668,#8597,#8252,#0182,#0167,#9644,#8616,
-        #8593,#8595,#8594,#8592,#8735,#8596,#9650,#9660
-      );
-      convert_cp437_to_UTF8:array[#127..#255] of WideChar=(
-                                                  #8962, { $7f }
-        #0199,#0252,#0233,#0226,#0228,#0224,#0229,#0231, { $80..$87 }
-        #0234,#0235,#0232,#0239,#0238,#0236,#0196,#0197, { $88..$8f }
-        #0201,#0230,#0198,#0244,#0246,#0242,#0251,#0249, { $90..$97 }
-        #0255,#0214,#0220,#0162,#0163,#0165,#8359,#0402, { $98..$9f }
-        #0225,#0237,#0243,#0250,#0241,#0209,#0170,#0186, { $a0..$a7 }
-        #0191,#8976,#0172,#0189,#0188,#0161,#0171,#0187, { $a8..$af }
-        #9617,#9618,#9619,#9474,#9508,#9569,#9570,#9558, { $b0..$b7 }
-        #9557,#9571,#9553,#9559,#9565,#9564,#9563,#9488, { $b8..$bf }
-        #9492,#9524,#9516,#9500,#9472,#9532,#9566,#9567, { $c0..$c7 }
-        #9562,#9556,#9577,#9574,#9568,#9552,#9580,#9575, { $c8..$cf }
-        #9576,#9572,#9573,#9561,#9560,#9554,#9555,#9579, { $d0..$d7 }
-        #9578,#9496,#9484,#9608,#9604,#9612,#9616,#9600, { $d8..$df }
-        #0945,#0223,#0915,#0960,#0931,#0963,#0181,#0964, { $e0..$e7 }
-        #0934,#0920,#0937,#0948,#8734,#0966,#0949,#8745, { $e8..$ef }
-        #8801,#0177,#8805,#8804,#8992,#8993,#0247,#8776, { $f0..$f7 }
-        #0176,#8729,#0183,#8730,#8319,#0178,#9632,#0160  { $f8..$ff }
-      );

+ 5 - 159
packages/rtl-console/src/unix/video.pp

@@ -40,19 +40,12 @@ const
 var external_codepage:TSystemCodePage;
 var external_codepage:TSystemCodePage;
 
 
 {$i video.inc}
 {$i video.inc}
-{$i convert.inc}
 
 
 type  Tconsole_type=(ttyNetwork
 type  Tconsole_type=(ttyNetwork
                      {$ifdef linux},ttyLinux{$endif}
                      {$ifdef linux},ttyLinux{$endif}
                      ,ttyFreeBSD
                      ,ttyFreeBSD
                      ,ttyNetBSD);
                      ,ttyNetBSD);
 
 
-      Tconversion=(cv_none,
-                   cv_cp437_to_iso01,
-                   cv_cp850_to_iso01,
-                   cv_linuxlowascii_to_vga,
-                   cv_cp437_to_UTF8);
-
       Ttermcode=(
       Ttermcode=(
         enter_alt_charset_mode,
         enter_alt_charset_mode,
         exit_alt_charset_mode,
         exit_alt_charset_mode,
@@ -195,8 +188,6 @@ const    terminal_names:array[0..11] of string[7]=(
                         @term_codes_xterm,
                         @term_codes_xterm,
                         @term_codes_beos);
                         @term_codes_beos);
 
 
-const convert:Tconversion=cv_none;
-
 var
 var
   LastCursorType : byte;
   LastCursorType : byte;
 {$ifdef linux}
 {$ifdef linux}
@@ -510,147 +501,11 @@ var
   LastCharWasDoubleWidth: Boolean;
   LastCharWasDoubleWidth: Boolean;
   CurCharWidth: Integer;
   CurCharWidth: Integer;
 
 
-  function transform_cp437_to_iso01(const st:string):string;
-
-  var i:byte;
-      c:char;
-      converted:word;
-
-  begin
-    transform_cp437_to_iso01:='';
-    for i:=1 to length(st) do
-      begin
-        c:=st[i];
-        case c of
-          #0..#31:
-            converted:=convert_lowascii_to_iso01[c];
-          #128..#255:
-            converted:=convert_cp437_to_iso01[c];
-          else
-            converted:=byte(c);
-        end;
-        if converted and $ff00=$f800 then
-          begin
-            if not in_ACS then
-              begin
-                transform_cp437_to_iso01:=transform_cp437_to_iso01+ACSIn;
-                in_ACS:=true;
-              end;
-            c:=char(converted and $ff);
-          end
-        else
-          if in_ACS then
-            begin
-              transform_cp437_to_iso01:=transform_cp437_to_iso01+ACSOut+
-                                        Attr2Ansi(LastAttr,0);
-              in_ACS:=false;
-            end;
-        transform_cp437_to_iso01:=transform_cp437_to_iso01+c;
-      end;
-  end;
-
-  function transform_cp850_to_iso01(const st:string):string;
-
-  var i:byte;
-      c:char;
-      converted:word;
-
-  begin
-    transform_cp850_to_iso01:='';
-    for i:=1 to length(st) do
-      begin
-        c:=st[i];
-        case c of
-          #0..#31:
-            converted:=convert_lowascii_to_iso01[c];
-          #128..#255:
-            converted:=convert_cp850_to_iso01[c];
-          else
-            converted:=byte(c);
-        end;
-        if converted and $ff00=$f800 then
-          begin
-            if not in_ACS then
-              begin
-                transform_cp850_to_iso01:=transform_cp850_to_iso01+ACSIn;
-                in_ACS:=true;
-              end;
-          end
-        else
-          if in_ACS then
-            begin
-              transform_cp850_to_iso01:=transform_cp850_to_iso01+ACSOut+
-                                        Attr2Ansi(LastAttr,0);
-              in_ACS:=false;
-            end;
-        c:=char(converted and $ff);
-        transform_cp850_to_iso01:=transform_cp850_to_iso01+c;
-      end;
-  end;
-
-  function transform_linuxlowascii_to_vga(const st:string):string;
-
-  var i:byte;
-      c:char;
-      converted:word;
-
-  begin
-    transform_linuxlowascii_to_vga:='';
-    for i:=1 to length(st) do
-      begin
-        c:=st[i];
-        case c of
-          #0..#31:
-            converted:=convert_linuxlowascii_to_vga[c];
-          else
-            converted:=byte(c);
-        end;
-        c:=char(converted and $ff);
-        transform_linuxlowascii_to_vga:=transform_linuxlowascii_to_vga+c;
-      end;
-  end;
-
-  function transform_cp437_to_UTF8(const st:string): string;
-  var i:byte;
-      c : char;
-      converted : WideChar;
-      s : WideString;
-  begin
-    s := '';
-    for i:=1 to length(st) do
-      begin
-        c:=st[i];
-        case c of
-          #0..#31:
-            converted:=convert_lowascii_to_UTF8[c];
-          #127..#255:
-            converted:=convert_cp437_to_UTF8[c];
-          else
-          begin
-            converted := #0;
-            converted := c;
-          end;
-        end;
-        s := s + converted;
-      end;
-    transform_cp437_to_UTF8 := Utf8Encode(s);  
-  end;
-  
   function transform(const hstr:UnicodeString):RawByteString;
   function transform(const hstr:UnicodeString):RawByteString;
-
   begin
   begin
-{    case convert of
-      cv_linuxlowascii_to_vga:
-        transform:=transform_linuxlowascii_to_vga(hstr);
-      cv_cp437_to_iso01:
-        transform:=transform_cp437_to_iso01(hstr);
-      cv_cp850_to_iso01:
-        transform:=transform_cp850_to_iso01(hstr);
-      cv_cp437_to_UTF8:
-        transform:=transform_cp437_to_UTF8(hstr);
-      else}
-        transform:=Utf8Encode(hstr);
-{    end;}
+    result:=Utf8Encode(hstr);
+    if external_codepage<>CP_UTF8 then
+      SetCodePage(result,external_codepage,True);
   end;
   end;
 
 
   procedure outdata(hstr:rawbytestring);
   procedure outdata(hstr:rawbytestring);
@@ -977,24 +832,15 @@ begin
         external_codepage:=850;
         external_codepage:=850;
     end;
     end;
   {A non-vcsa Linux console can display most control characters, but not all.}
   {A non-vcsa Linux console can display most control characters, but not all.}
-  if {$ifdef linux}(console<>ttyLinux) and{$endif}
-     (cur_term_strings=@term_codes_linux) then
-    convert:=cv_linuxlowascii_to_vga;
   case external_codepage of
   case external_codepage of
     CP_ISO01:            {West Europe}
     CP_ISO01:            {West Europe}
-      begin
-        CurrentLegacy2EnhancedTranslationCodePage:=850;
-        convert:=cv_cp850_to_iso01;
-      end;
+      CurrentLegacy2EnhancedTranslationCodePage:=850;
     CP_ISO02:            {East Europe}
     CP_ISO02:            {East Europe}
       CurrentLegacy2EnhancedTranslationCodePage:=852;
       CurrentLegacy2EnhancedTranslationCodePage:=852;
     CP_ISO05:            {Cyrillic}
     CP_ISO05:            {Cyrillic}
       CurrentLegacy2EnhancedTranslationCodePage:=866;
       CurrentLegacy2EnhancedTranslationCodePage:=866;
     CP_UTF8:
     CP_UTF8:
-      begin
-        CurrentLegacy2EnhancedTranslationCodePage:=437;
-        convert:=cv_cp437_to_UTF8;
-      end;
+      CurrentLegacy2EnhancedTranslationCodePage:=437;
     else
     else
       if is_vga_code_page(external_codepage) then
       if is_vga_code_page(external_codepage) then
         CurrentLegacy2EnhancedTranslationCodePage:=external_codepage
         CurrentLegacy2EnhancedTranslationCodePage:=external_codepage