Recent

Author Topic: Extended ascii characters #128-#255  (Read 889 times)

Lauriet

  • New Member
  • *
  • Posts: 20
Extended ascii characters #128-#255
« on: February 16, 2025, 02:43:27 am »
I have been going around in circles with this issue. I have searched but this adds to my confusion.
I want to be able to use Write(#205) for instance in the terminal and get the line drawing chars.
Now I know that terminal is set to UTF8 and this is a different scheme to the old dos/ascii
I've tried to set {$CODEPAGE cp437}. I've tried Write(#$2500) since this is the UTF8 area for the line drawing chars. I've tried to read thru fv with only a hints on how to do it.

Do i need to change to another font (how)
Do i set the terminal for cp437(how)

I am using MxLinux.

Does anyone have a SIMPLE solution. If you do, please explain like i'm a 6 year old.  :(
« Last Edit: February 16, 2025, 06:19:37 am by Lauriet »

paweld

  • Hero Member
  • *****
  • Posts: 1330
Re: Extended ascii characters #128-#255
« Reply #1 on: February 16, 2025, 06:52:05 am »
In my opinion, it will be simpler to convert characters to the UTF-8 equivalent. Lazarus has a LConvEncoding unit that allows you to convert character encodings, among others, from CP437 to UTF-8 - Important: you need to add the LCLBase package to the project requirements (if not already included).
Sample:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Classes, SysUtils, LConvEncoding;
  7.  
  8. begin
  9.   WriteLn(CP437ToUTF8(#201#205#205#205#187));
  10.   WriteLn(CP437ToUTF8(#186#178#32#178#186));
  11.   WriteLn(CP437ToUTF8(#186#32#178#32#186));
  12.   WriteLn(CP437ToUTF8(#186#178#32#178#186));
  13.   WriteLn(CP437ToUTF8(#200#205#205#205#188));
  14.   ReadLn;
  15. end.  
« Last Edit: February 16, 2025, 06:54:00 am by paweld »
Best regards / Pozdrawiam
paweld

Thaddy

  • Hero Member
  • *****
  • Posts: 16665
  • Kallstadt seems a good place to evict Trump to.
Re: Extended ascii characters #128-#255
« Reply #2 on: February 16, 2025, 07:15:26 am »
Like this, cross platform?
Code: Pascal  [Select][+][-]
  1. program DrawBox;
  2. { cross platform utf8 box drawing }
  3. {$mode objfpc}
  4. uses
  5. {$ifdef unix}
  6.   cthreads,
  7. {$endif}
  8.   sysutils;
  9. const
  10.   // UTF-8 box-drawing characters
  11.   TopLeftCorner     = '┌';
  12.   TopRightCorner    = '┐';
  13.   BottomLeftCorner  = '└';
  14.   BottomRightCorner = '┘';
  15.   HorizontalLine    = '─';
  16.   VerticalLine      = '│';
  17.   // UTF-8 double-line box-drawing characters
  18.   TopLeftCorner D    = '╔';
  19.   TopRightCornerD    = '╗';
  20.   BottomLeftCornerD  = '╚';
  21.   BottomRightCornerD = '╝';
  22.   HorizontalLineD    = '═';
  23.   VerticalLineD      = '║';
  24.  
  25. procedure DrawBox(width, height: Integer);
  26. var
  27.   x, y: Integer;
  28. begin
  29.   // Ensure minimum box size
  30.   if width < 2 then width := 2;
  31.   if height < 2 then height := 2;
  32.  
  33.   // Draw the top border
  34.   Write(TopLeftCorner);
  35.   for x := 2 to width - 1 do
  36.     Write(HorizontalLine);
  37.   WriteLn(TopRightCorner);
  38.  
  39.   // Draw the middle rows
  40.   for y := 2 to height - 1 do
  41.   begin
  42.     Write(VerticalLine);
  43.     for x := 2 to width - 1 do
  44.       Write(' ');
  45.     WriteLn(VerticalLine);
  46.   end;
  47.  
  48.   // Draw the bottom border
  49.   Write(BottomLeftCorner);
  50.   for x := 2 to width - 1 do
  51.     Write(HorizontalLine);
  52.   WriteLn(BottomRightCorner);
  53. end;
  54.  
  55. begin
  56.   // Set UTF-8 output mode (required for proper display of box-drawing characters)
  57.   SetTextCodePage(Output, CP_UTF8);
  58.  
  59.   // Draw a box with a width of 20 and height of 10
  60.   DrawBox(20, 10);
  61. end.
  62.  

1. you can use use ncurses. It comes with a whole host of demo's.
2. you can uses freevision.
Both can create quite complex user interfaces.
 
« Last Edit: February 16, 2025, 07:40:22 am by Thaddy »
But I am sure they don't want the Trumps back...

Thaddy

  • Hero Member
  • *****
  • Posts: 16665
  • Kallstadt seems a good place to evict Trump to.
Re: Extended ascii characters #128-#255
« Reply #3 on: February 16, 2025, 07:17:08 am »
In my opinion,
Well, not my opinion but that code would work too.
It can be a helluvelot simpler, though.
But I am sure they don't want the Trumps back...

Lauriet

  • New Member
  • *
  • Posts: 20
Re: Extended ascii characters #128-#255
« Reply #4 on: February 17, 2025, 01:53:12 am »
PAWELD: this one works,

but the "DrawBox"
does not work in a console.
Maybe in a GUI, but it just prints out ???? characters.

My issue is that I want to have a console TUI
« Last Edit: February 17, 2025, 02:08:02 am by Lauriet »

Lauriet

  • New Member
  • *
  • Posts: 20
Re: Extended ascii characters #128-#255
« Reply #5 on: February 17, 2025, 03:16:24 am »
Thanks Paweld.

If I strip away all the extra stuff in LconvEncoding, I get what i want.......simple code that shows how my simple needs are implemented:

P.S. I still don't know who to insert code properly ???

unit
  Cp437;

{$H+}
interface

function CP437ToUTF8(const s: string): string;

implementation

type
  TCharToUTF8Table = array[Char] Of PChar;

const
  ArrayCP437ToUTF8 : TCharToUTF8Table = (
    #0,                 // #0
    #1,                 // #1
    #2,                 // #2
    #3,                 // #3
    #4,                 // #4
    #5,                 // #5
    #6,                 // #6
    #7,                 // #7
    #8,                 // #8
    #9,                 // #9
    #10,                // #10
    #11,                // #11
    #12,                // #12
    #13,                // #13
    #14,                // #14
    #15,                // #15
    #16,                // #16
    #17,                // #17
    #18,                // #18
    #19,                // #19
    #20,                // #20
    #21,                // #21
    #22,                // #22
    #23,                // #23
    #24,                // #24
    #25,                // #25
    #26,                // #26
    #27,                // #27
    #28,                // #28
    #29,                // #29
    #30,                // #30
    #31,                // #31
    ' ',                // ' '
    '!',                // '!'
    '"',                // '"'
    '#',                // '#'
    '$',                // '$'
    '%',                // '%'
    '&',                // '&'
    '''',               // ''''
    '(',                // '('
    ')',                // ')'
    '*',                // '*'
    '+',                // '+'
    ',',                // ','
    '-',                // '-'
    '.',                // '.'
    '/',                // '/'
    '0',                // '0'
    '1',                // '1'
    '2',                // '2'
    '3',                // '3'
    '4',                // '4'
    '5',                // '5'
    '6',                // '6'
    '7',                // '7'
    '8',                // '8'
    '9',                // '9'
    ':',                // ':'
    ';',                // ';'
    '<',                // '<'
    '=',                // '='
    '>',                // '>'
    '?',                // '?'
    '@',                // '@'
    'A',                // 'A'
    'B',                // 'B'
    'C',                // 'C'
    'D',                // 'D'
    'E',                // 'E'
    'F',                // 'F'
    'G',                // 'G'
    'H',                // 'H'
    'I',                // 'I'
    'J',                // 'J'
    'K',                // 'K'
    'L',                // 'L'
    'M',                // 'M'
    'N',                // 'N'
    'O',                // 'O'
    'P',                // 'P'
    'Q',                // 'Q'
    'R',                // 'R'
    'S',                // 'S'
    'T',                // 'T'
    'U',                // 'U'
    'V',                // 'V'
    'W',                // 'W'
    'X',                // 'X'
    'Y',                // 'Y'
    'Z',                // 'Z'
    '[',                // '['
    '\',                // '\'
    ']',                // ']'
    '^',                // '^'
    '_',                // '_'
    '`',                // '`'
    'a',                // 'a'
    'b',                // 'b'
    'c',                // 'c'
    'd',                // 'd'
    'e',                // 'e'
    'f',                // 'f'
    'g',                // 'g'
    'h',                // 'h'
    'i',                // 'i'
    'j',                // 'j'
    'k',                // 'k'
    'l',                // 'l'
    'm',                // 'm'
    'n',                // 'n'
    'o',                // 'o'
    'p',                // 'p'
    'q',                // 'q'
    'r',                // 'r'
    's',                // 's'
    't',                // 't'
    'u',                // 'u'
    'v',                // 'v'
    'w',                // 'w'
    'x',                // 'x'
    'y',                // 'y'
    'z',                // 'z'
    '{',                // '{'
    '|',                // '|'
    '}',                // '}'
    '~',                // '~'
    #127,               // #127
    #195#135,           // #128
    #195#188,           // #129
    #195#169,           // #130
    #195#162,           // #131
    #195#164,           // #132
    #195#160,           // #133
    #195#165,           // #134
    #195#167,           // #135
    #195#170,           // #136
    #195#171,           // #137
    #195#168,           // #138
    #195#175,           // #139
    #195#174,           // #140
    #195#172,           // #141
    #195#132,           // #142
    #195#133,           // #143
    #195#137,           // #144
    #195#166,           // #145
    #195#134,           // #146
    #195#180,           // #147
    #195#182,           // #148
    #195#178,           // #149
    #195#187,           // #150
    #195#185,           // #151
    #195#191,           // #152
    #195#150,           // #153
    #195#156,           // #154
    #194#162,           // #155
    #194#163,           // #156
    #194#165,           // #157
    #226#130#167,       // #158
    #198#146,           // #159
    #195#161,           // #160
    #195#173,           // #161
    #195#179,           // #162
    #195#186,           // #163
    #195#177,           // #164
    #195#145,           // #165
    #194#170,           // #166
    #194#186,           // #167
    #194#191,           // #168
    #226#140#144,       // #169
    #194#172,           // #170
    #194#189,           // #171
    #194#188,           // #172
    #194#161,           // #173
    #194#171,           // #174
    #194#187,           // #175
    #226#150#145,       // #176
    #226#150#146,       // #177
    #226#150#147,       // #178
    #226#148#130,       // #179
    #226#148#164,       // #180
    #226#149#161,       // #181
    #226#149#162,       // #182
    #226#149#150,       // #183
    #226#149#149,       // #184
    #226#149#163,       // #185
    #226#149#145,       // #186
    #226#149#151,       // #187
    #226#149#157,       // #188
    #226#149#156,       // #189
    #226#149#155,       // #190
    #226#148#144,       // #191
    #226#148#148,       // #192
    #226#148#180,       // #193
    #226#148#172,       // #194
    #226#148#156,       // #195
    #226#148#128,       // #196
    #226#148#188,       // #197
    #226#149#158,       // #198
    #226#149#159,       // #199
    #226#149#154,       // #200
    #226#149#148,       // #201
    #226#149#169,       // #202
    #226#149#166,       // #203
    #226#149#160,       // #204
    #226#149#144,       // #205
    #226#149#172,       // #206
    #226#149#167,       // #207
    #226#149#168,       // #208
    #226#149#164,       // #209
    #226#149#165,       // #210
    #226#149#153,       // #211
    #226#149#152,       // #212
    #226#149#146,       // #213
    #226#149#147,       // #214
    #226#149#171,       // #215
    #226#149#170,       // #216
    #226#148#152,       // #217
    #226#148#140,       // #218
    #226#150#136,       // #219
    #226#150#132,       // #220
    #226#150#140,       // #221
    #226#150#144,       // #222
    #226#150#128,       // #223
    #206#177,           // #224
    #195#159,           // #225
    #206#147,           // #226
    #207#128,           // #227
    #206#163,           // #228
    #207#131,           // #229
    #194#181,           // #230
    #207#132,           // #231
    #206#166,           // #232
    #206#152,           // #233
    #206#169,           // #234
    #206#180,           // #235
    #226#136#158,       // #236
    #207#134,           // #237
    #206#181,           // #238
    #226#136#169,       // #239
    #226#137#161,       // #240
    #194#177,           // #241
    #226#137#165,       // #242
    #226#137#164,       // #243
    #226#140#160,       // #244
    #226#140#161,       // #245
    #195#183,           // #246
    #226#137#136,       // #247
    #194#176,           // #248
    #226#136#153,       // #249
    #194#183,           // #250
    #226#136#154,       // #251
    #226#129#191,       // #252
    #194#178,           // #253
    #226#150#160,       // #254
    #194#160            // #255
  );



function SingleByteToUTF8(const s : string; const Table : TCharToUTF8Table) : string;
var
  len,
  i    : Integer;
  Src  : PChar;
  Dest : PChar;
  p    : PChar;
  c    : Char;
begin
  if s= '' then begin
    Result:='';
    exit;
  end;
  len := length(s);
  SetLength(Result, len*4);// UTF-8 is at most 4 bytes
  Src := PChar(s);
  Dest := PChar(Result);
  for i := 1 to len do
    begin
      c := Src^;
      inc(Src);
      if ord(c) < 128 then
        begin
          Dest^ := c;
          inc(Dest);
        end
      else
        begin
          p := Table[c];
          if p <> nil then
            while p^ <> #0 do
              begin
                Dest^ := p^;
                inc(p);
                inc(Dest);
              end;
        end;
    end;
  SetLength(Result, {%H-}PtrUInt(Dest)-PtrUInt(Result));
end;


function CP437ToUTF8(const s: string): string;
begin
  Result := SingleByteToUTF8(s, ArrayCP437ToUTF8);
end;


begin
end.

440bx

  • Hero Member
  • *****
  • Posts: 5081
Re: Extended ascii characters #128-#255
« Reply #6 on: February 17, 2025, 03:25:52 am »
P.S. I still don't know who to insert code properly ???
Tell your browser to show you the source code for this page and pay attention to the tags: [ code = pascal ] and [ / code ] (without spaces.)

You should see the code formatting tags immediately after this line

Code: Pascal  [Select][+][-]
  1. unit
  2.   Cp437;
  3.  
  4. {$H+}
  5. interface
  6.  
  7. function CP437ToUTF8(const s: string): string;
  8.  
  9. implementation
  10.  
  11. type
  12.   TCharToUTF8Table = array[Char] Of PChar;
  13.  
  14. const
  15.   ArrayCP437ToUTF8 : TCharToUTF8Table = (
  16.     #0,                 // #0
  17.     #1,                 // #1
  18.     #2,                 // #2
  19.     #3,                 // #3
  20.     #4,                 // #4
  21.     #5,                 // #5
  22.     #6,                 // #6
  23.     #7,                 // #7
  24.     #8,                 // #8
  25.     #9,                 // #9
  26.     #10,                // #10
  27.     #11,                // #11
  28.     #12,                // #12
  29.     #13,                // #13
  30.     #14,                // #14
  31.     #15,                // #15
  32.     #16,                // #16
  33.     #17,                // #17
  34.     #18,                // #18
  35.     #19,                // #19
  36.     #20,                // #20
  37.     #21,                // #21
  38.     #22,                // #22
  39.     #23,                // #23
  40.     #24,                // #24
  41.     #25,                // #25
  42.     #26,                // #26
  43.     #27,                // #27
  44.     #28,                // #28
  45.     #29,                // #29
  46.     #30,                // #30
  47.     #31,                // #31
  48.     ' ',                // ' '
  49.     '!',                // '!'
  50.     '"',                // '"'
  51.     '#',                // '#'
  52.     '$',                // '$'
  53.     '%',                // '%'
  54.     '&',                // '&'
  55.     '''',               // ''''
  56.     '(',                // '('
  57.     ')',                // ')'
  58.     '*',                // '*'
  59.     '+',                // '+'
  60.     ',',                // ','
  61.     '-',                // '-'
  62.     '.',                // '.'
  63.     '/',                // '/'
  64.     '0',                // '0'
  65.     '1',                // '1'
  66.     '2',                // '2'
  67.     '3',                // '3'
  68.     '4',                // '4'
  69.     '5',                // '5'
  70.     '6',                // '6'
  71.     '7',                // '7'
  72.     '8',                // '8'
  73.     '9',                // '9'
  74.     ':',                // ':'
  75.     ';',                // ';'
  76.     '<',                // '<'
  77.     '=',                // '='
  78.     '>',                // '>'
  79.     '?',                // '?'
  80.     '@',                // '@'
  81.     'A',                // 'A'
  82.     'B',                // 'B'
  83.     'C',                // 'C'
  84.     'D',                // 'D'
  85.     'E',                // 'E'
  86.     'F',                // 'F'
  87.     'G',                // 'G'
  88.     'H',                // 'H'
  89.     'I',                // 'I'
  90.     'J',                // 'J'
  91.     'K',                // 'K'
  92.     'L',                // 'L'
  93.     'M',                // 'M'
  94.     'N',                // 'N'
  95.     'O',                // 'O'
  96.     'P',                // 'P'
  97.     'Q',                // 'Q'
  98.     'R',                // 'R'
  99.     'S',                // 'S'
  100.     'T',                // 'T'
  101.     'U',                // 'U'
  102.     'V',                // 'V'
  103.     'W',                // 'W'
  104.     'X',                // 'X'
  105.     'Y',                // 'Y'
  106.     'Z',                // 'Z'
  107.     '[',                // '['
  108.     '\',                // '\'
  109.     ']',                // ']'
  110.     '^',                // '^'
  111.     '_',                // '_'
  112.     '`',                // '`'
  113.     'a',                // 'a'
  114.     'b',                // 'b'
  115.     'c',                // 'c'
  116.     'd',                // 'd'
  117.     'e',                // 'e'
  118.     'f',                // 'f'
  119.     'g',                // 'g'
  120.     'h',                // 'h'
  121.     'i',                // 'i'
  122.     'j',                // 'j'
  123.     'k',                // 'k'
  124.     'l',                // 'l'
  125.     'm',                // 'm'
  126.     'n',                // 'n'
  127.     'o',                // 'o'
  128.     'p',                // 'p'
  129.     'q',                // 'q'
  130.     'r',                // 'r'
  131.     's',                // 's'
  132.     't',                // 't'
  133.     'u',                // 'u'
  134.     'v',                // 'v'
  135.     'w',                // 'w'
  136.     'x',                // 'x'
  137.     'y',                // 'y'
  138.     'z',                // 'z'
  139.     '{',                // '{'
  140.     '|',                // '|'
  141.     '}',                // '}'
  142.     '~',                // '~'
  143.     #127,               // #127
  144.     #195#135,           // #128
  145.     #195#188,           // #129
  146.     #195#169,           // #130
  147.     #195#162,           // #131
  148.     #195#164,           // #132
  149.     #195#160,           // #133
  150.     #195#165,           // #134
  151.     #195#167,           // #135
  152.     #195#170,           // #136
  153.     #195#171,           // #137
  154.     #195#168,           // #138
  155.     #195#175,           // #139
  156.     #195#174,           // #140
  157.     #195#172,           // #141
  158.     #195#132,           // #142
  159.     #195#133,           // #143
  160.     #195#137,           // #144
  161.     #195#166,           // #145
  162.     #195#134,           // #146
  163.     #195#180,           // #147
  164.     #195#182,           // #148
  165.     #195#178,           // #149
  166.     #195#187,           // #150
  167.     #195#185,           // #151
  168.     #195#191,           // #152
  169.     #195#150,           // #153
  170.     #195#156,           // #154
  171.     #194#162,           // #155
  172.     #194#163,           // #156
  173.     #194#165,           // #157
  174.     #226#130#167,       // #158
  175.     #198#146,           // #159
  176.     #195#161,           // #160
  177.     #195#173,           // #161
  178.     #195#179,           // #162
  179.     #195#186,           // #163
  180.     #195#177,           // #164
  181.     #195#145,           // #165
  182.     #194#170,           // #166
  183.     #194#186,           // #167
  184.     #194#191,           // #168
  185.     #226#140#144,       // #169
  186.     #194#172,           // #170
  187.     #194#189,           // #171
  188.     #194#188,           // #172
  189.     #194#161,           // #173
  190.     #194#171,           // #174
  191.     #194#187,           // #175
  192.     #226#150#145,       // #176
  193.     #226#150#146,       // #177
  194.     #226#150#147,       // #178
  195.     #226#148#130,       // #179
  196.     #226#148#164,       // #180
  197.     #226#149#161,       // #181
  198.     #226#149#162,       // #182
  199.     #226#149#150,       // #183
  200.     #226#149#149,       // #184
  201.     #226#149#163,       // #185
  202.     #226#149#145,       // #186
  203.     #226#149#151,       // #187
  204.     #226#149#157,       // #188
  205.     #226#149#156,       // #189
  206.     #226#149#155,       // #190
  207.     #226#148#144,       // #191
  208.     #226#148#148,       // #192
  209.     #226#148#180,       // #193
  210.     #226#148#172,       // #194
  211.     #226#148#156,       // #195
  212.     #226#148#128,       // #196
  213.     #226#148#188,       // #197
  214.     #226#149#158,       // #198
  215.     #226#149#159,       // #199
  216.     #226#149#154,       // #200
  217.     #226#149#148,       // #201
  218.     #226#149#169,       // #202
  219.     #226#149#166,       // #203
  220.     #226#149#160,       // #204
  221.     #226#149#144,       // #205
  222.     #226#149#172,       // #206
  223.     #226#149#167,       // #207
  224.     #226#149#168,       // #208
  225.     #226#149#164,       // #209
  226.     #226#149#165,       // #210
  227.     #226#149#153,       // #211
  228.     #226#149#152,       // #212
  229.     #226#149#146,       // #213
  230.     #226#149#147,       // #214
  231.     #226#149#171,       // #215
  232.     #226#149#170,       // #216
  233.     #226#148#152,       // #217
  234.     #226#148#140,       // #218
  235.     #226#150#136,       // #219
  236.     #226#150#132,       // #220
  237.     #226#150#140,       // #221
  238.     #226#150#144,       // #222
  239.     #226#150#128,       // #223
  240.     #206#177,           // #224
  241.     #195#159,           // #225
  242.     #206#147,           // #226
  243.     #207#128,           // #227
  244.     #206#163,           // #228
  245.     #207#131,           // #229
  246.     #194#181,           // #230
  247.     #207#132,           // #231
  248.     #206#166,           // #232
  249.     #206#152,           // #233
  250.     #206#169,           // #234
  251.     #206#180,           // #235
  252.     #226#136#158,       // #236
  253.     #207#134,           // #237
  254.     #206#181,           // #238
  255.     #226#136#169,       // #239
  256.     #226#137#161,       // #240
  257.     #194#177,           // #241
  258.     #226#137#165,       // #242
  259.     #226#137#164,       // #243
  260.     #226#140#160,       // #244
  261.     #226#140#161,       // #245
  262.     #195#183,           // #246
  263.     #226#137#136,       // #247
  264.     #194#176,           // #248
  265.     #226#136#153,       // #249
  266.     #194#183,           // #250
  267.     #226#136#154,       // #251
  268.     #226#129#191,       // #252
  269.     #194#178,           // #253
  270.     #226#150#160,       // #254
  271.     #194#160            // #255
  272.   );
  273.  
  274.  
  275.  
  276. function SingleByteToUTF8(const s : string; const Table : TCharToUTF8Table) : string;
  277. var
  278.   len,
  279.   i    : Integer;
  280.   Src  : PChar;
  281.   Dest : PChar;
  282.   p    : PChar;
  283.   c    : Char;
  284. begin
  285.   if s= '' then begin
  286.     Result:='';
  287.     exit;
  288.   end;
  289.   len := length(s);
  290.   SetLength(Result, len*4);// UTF-8 is at most 4 bytes
  291.   Src := PChar(s);
  292.   Dest := PChar(Result);
  293.   for i := 1 to len do
  294.     begin
  295.       c := Src^;
  296.       inc(Src);
  297.       if ord(c) < 128 then
  298.         begin
  299.           Dest^ := c;
  300.           inc(Dest);
  301.         end
  302.       else
  303.         begin
  304.           p := Table[c];
  305.           if p <> nil then
  306.             while p^ <> #0 do
  307.               begin
  308.                 Dest^ := p^;
  309.                 inc(p);
  310.                 inc(Dest);
  311.               end;
  312.         end;
  313.     end;
  314.   SetLength(Result, {%H-}PtrUInt(Dest)-PtrUInt(Result));
  315. end;
  316.  
  317.  
  318. function CP437ToUTF8(const s: string): string;
  319. begin
  320.   Result := SingleByteToUTF8(s, ArrayCP437ToUTF8);
  321. end;
  322.  
  323.  
  324. begin
  325. end.
  326.  

ETA:

Put your code between the tags [code=pascal] <your Pascal code here> [/code] to have it output as formatted above.

« Last Edit: February 17, 2025, 11:12:43 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16665
  • Kallstadt seems a good place to evict Trump to.
Re: Extended ascii characters #128-#255
« Reply #7 on: February 17, 2025, 07:37:42 am »
but the "DrawBox"
You said you are on Linux. On Linux the drawbox code works since Linux terminals are almost all UTF-8 by default.
But if you are on Windows, your console needs to be in Unicode mode. You can do that in code or through the console properties, but then you should have told me you are on Windows.
But I am sure they don't want the Trumps back...

Lauriet

  • New Member
  • *
  • Posts: 20
Re: Extended ascii characters #128-#255
« Reply #8 on: February 17, 2025, 07:56:40 am »
Errr,
what is this Windows you speak off ????? :D

Thaddy

  • Hero Member
  • *****
  • Posts: 16665
  • Kallstadt seems a good place to evict Trump to.
Re: Extended ascii characters #128-#255
« Reply #9 on: February 17, 2025, 09:05:21 am »
Well, you wrote my drawbox fails, which it doesn't on all my nix boxes in several dialects of Linux....
You also use the term "console" which is windows speak for "terminal"
....

The code works as expected and cross platform. You must be doing something strange.
« Last Edit: February 17, 2025, 09:08:39 am by Thaddy »
But I am sure they don't want the Trumps back...

PascalDragon

  • Hero Member
  • *****
  • Posts: 5909
  • Compiler Developer
Re: Extended ascii characters #128-#255
« Reply #10 on: February 17, 2025, 08:58:17 pm »
P.S. I still don't know who to insert code properly ???
Tell your browser to show you the source code for this page and pay attention to the tags: [ code = pascal ] and [ / code ] (without spaces.)

What would viewing the source code of the page help here? It would just be a collection of <div>s. 🤔 Using the Quote action on the other hand would be better.

Also, side note, you can use [nobbc][/nobbc] to display tags without the forum interpreting them, e.g. [code][/code], so you don't need to add spaces. 😁

440bx

  • Hero Member
  • *****
  • Posts: 5081
Re: Extended ascii characters #128-#255
« Reply #11 on: February 17, 2025, 11:07:44 pm »
What would viewing the source code of the page help here?
You're right, my mistake, I totally forgot that the tags would cause the text to be formatted.  IOW, the action isn't carried out by the browser, therefore the tags do not appear in the page source.

Also, side note, you can use [nobbc][/nobbc] to display tags without the forum interpreting them, e.g. [code][/code], so you don't need to add spaces. 😁
Useful information.  Thank you for that PascalDragon.

ETA:

Corrected original message.
« Last Edit: February 17, 2025, 11:13:27 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Lauriet

  • New Member
  • *
  • Posts: 20
Re: Extended ascii characters #128-#255
« Reply #12 on: February 18, 2025, 02:13:36 am »
Thaddy your right.
I originally typed it in.
When I did a copy/paste it worked, because it took the UTF8 chars and added the extra 2 bytes that are part of the UTF8 encoding.

P.S. You dont need setcodepage statement for it to work.

So...... terminal on my machine is set to UTF8 and the drawing characters require 3 bytes to display them.

Thaddy

  • Hero Member
  • *****
  • Posts: 16665
  • Kallstadt seems a good place to evict Trump to.
Re: Extended ascii characters #128-#255
« Reply #13 on: February 18, 2025, 08:42:19 am »
P.S. You dont need setcodepage statement for it to work.
Yes, you do to make it cross platform, but on linux you can probably leave it out. I would keep it, just in case.
But I am sure they don't want the Trumps back...

 

TinyPortal © 2005-2018