Old ASCII box making characters. lazarus / 21-General ---------------------------------------------------------------------- OC DelGuy · 2021-02-05 01:02 I write a lot of output to TMemo boxes. Sometimes I'd like to format some data inside little boxes which makes it easier to understand and looks good. Is there a way to make the old DOS ASCII code box characters appear in a TMemo? ---------------------------------------------------------------------- egsuh · 2021-02-05 01:31 I can make it with Korean characters. Character codes may different depending on your language. Find the ascii codes and try them if you are using English OS. ---------------------------------------------------------------------- lucamar · 2021-02-05 01:55 Quote from: OC DelGuy on February 05, 2021, 02:02:34 amIs there a way to make the old DOS ASCII code box characters appear in a TMemo? Yes, but instead of the Extended ASCII you have to use the Unicode ones ... but I don't know what code-points they have, sorry They should be easy to find, though. Also, the font your memo is using (or the system fallback one) must have the corresponding graphs. ETA: Found'em! Unicode block U+2500-U+25FF; most any "charmap" type program will show them to you ---------------------------------------------------------------------- OC DelGuy · 2021-02-05 04:08 Quote from: lucamar on February 05, 2021, 02:55:37 amQuote from: OC DelGuy on February 05, 2021, 02:02:34 amIs there a way to make the old DOS ASCII code box characters appear in a TMemo? Yes, but instead of the Extended ASCII you have to use the Unicode ones ... but I don't know what code-points they have, sorry They should be easy to find, though. Also, the font your memo is using (or the system fallback one) must have the corresponding graphs. ETA: Found'em! Unicode block U+2500-U+25FF; most any "charmap" type program will show them to you How do you get to the Unicode Characters?  I know the chr(x) function, but that's for ASCII.  What is the function for Unicode? ---------------------------------------------------------------------- skalogryz · 2021-02-05 04:37 Quote from: OC DelGuy on February 05, 2021, 05:08:34 amHow do you get to the Unicode Characters?  I know the chr(x) function, but that's for ASCII.  What is the function for Unicode? It's a bit more complicated in case of TMemo. Since it's using UTF8. Here's an example Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // these are unicodesconst  BOX_Horz       = #$2500;  BOX_Right_Down = #$250C;  BOX_Left_Down  = #$2510;  BOX_Vert       = #$2502;  BOX_Right_Up   = #$2514;  BOX_Left_Up    = #$2518; function LikeAnASCII(const s: string): string;var  ws : WideString;  i  : integer;begin  ws := UTF8Decode(s);  for i:=1 to length(ws) do    case ws[i] of      'l','L': ws[i]:=BOX_Right_Up;      'j','J': ws[i]:=BOX_Left_Up;      '-': ws[i]:=BOX_Horz;      '/': ws[i]:=BOX_Right_Down;      '\': ws[i]:=BOX_Left_Down;      '|': ws[i]:=BOX_Vert;    end;  Result := UTF8Encode(ws);end; procedure TForm1.Button1Click(Sender: TObject);var  ws : WideString;begin  Memo1.Clear;  // But we convert unicodes into UTF8 for TMemo to handle it  Memo1.Lines.Add( Utf8Encode (BOX_Right_Down+BOX_Horz+BOX_Horz+BOX_Horz+BOX_Horz+BOX_Left_Down));  Memo1.Lines.Add( Utf8Encode(BOX_Vert+' '+' '+' '+' '+BOX_Vert));  Memo1.Lines.Add( Utf8Encode(BOX_Vert+' '+' '+' '+' '+BOX_Vert));  Memo1.Lines.Add( Utf8Encode(BOX_Right_Up+BOX_Horz+BOX_Horz+BOX_Horz+BO X_Horz+BOX_Left_Up));  // or one might want to use a handy function  Memo1.Lines.Add( LikeAnASCII('/-------\ '));  Memo1.Lines.Add( LikeAnASCII('|       |'));  Memo1.Lines.Add( LikeAnASCII('|       |'));  Memo1.Lines.Add( LikeAnASCII('|       |'));  Memo1.Lines.Add( LikeAnASCII('L-------J '));  // or just trust FPC to use UTF8 strings  // but you might want to add {$codepage utf8} at the start of the unit  Memo1.Lines.Add( '┌────┐');  Memo1.Lines.Add( '│    │');  Memo1.Lines.Add( '│    │');  Memo1.Lines.Add( '└────┘');end;     PS: but honestly, i'd suggest to go with plus signs "+", pipes "|", dashes "-" and underscores "_" ---------------------------------------------------------------------- lucamar · 2021-02-05 05:13 Quote from: OC DelGuy on February 05, 2021, 05:08:34 amHow do you get to the Unicode Characters?  I know the chr(x) function, but that's for ASCII.  What is the function for Unicode? Use the normal notation for char constants: MyChar := #$2500; That "#$2500" means "the char whose (hexadecimal) code is 2500", i.e. U+2500. Of course, MyChar has to be a WideChar for this to work See: WideChar in the Reference Guide. ETA: Yeah, as skalogryz already showed ---------------------------------------------------------------------- OC DelGuy · 2021-02-05 12:13 Quote from: skalogryz on February 05, 2021, 05:37:16 amQuote from: OC DelGuy on February 05, 2021, 05:08:34 amHow do you get to the Unicode Characters?  I know the chr(x) function, but that's for ASCII.  What is the function for Unicode? It's a bit more complicated in case of TMemo. Since it's using UTF8. Here's an example Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // these are unicodesconst  BOX_Horz       = #$2500;  BOX_Right_Down = #$250C;  BOX_Left_Down  = #$2510;  BOX_Vert       = #$2502;  BOX_Right_Up   = #$2514;  BOX_Left_Up    = #$2518; function LikeAnASCII(const s: string): string;var  ws : WideString;  i  : integer;begin  ws := UTF8Decode(s);  for i:=1 to length(ws) do    case ws[i] of      'l','L': ws[i]:=BOX_Right_Up;      'j','J': ws[i]:=BOX_Left_Up;      '-': ws[i]:=BOX_Horz;      '/': ws[i]:=BOX_Right_Down;      '\': ws[i]:=BOX_Left_Down;      '|': ws[i]:=BOX_Vert;    end;  Result := UTF8Encode(ws);end; procedure TForm1.Button1Click(Sender: TObject);var  ws : WideString;begin  Memo1.Clear;  // But we convert unicodes into UTF8 for TMemo to handle it  Memo1.Lines.Add( Utf8Encode (BOX_Right_Down+BOX_Horz+BOX_Horz+BOX_Horz+BOX_Horz+BOX_Left_Down));  Memo1.Lines.Add( Utf8Encode(BOX_Vert+' '+' '+' '+' '+BOX_Vert));  Memo1.Lines.Add( Utf8Encode(BOX_Vert+' '+' '+' '+' '+BOX_Vert));  Memo1.Lines.Add( Utf8Encode(BOX_Right_Up+BOX_Horz+BOX_Horz+BOX_Horz+BO X_Horz+BOX_Left_Up));  // or one might want to use a handy function  Memo1.Lines.Add( LikeAnASCII('/-------\ '));  Memo1.Lines.Add( LikeAnASCII('|       |'));  Memo1.Lines.Add( LikeAnASCII('|       |'));  Memo1.Lines.Add( LikeAnASCII('|       |'));  Memo1.Lines.Add( LikeAnASCII('L-------J '));  // or just trust FPC to use UTF8 strings  // but you might want to add {$codepage utf8} at the start of the unit  Memo1.Lines.Add( '┌────┐');  Memo1.Lines.Add( '│    │');  Memo1.Lines.Add( '│    │');  Memo1.Lines.Add( '└────┘');end;     PS: but honestly, i'd suggest to go with plus signs "+", pipes "|", dashes "-" and underscores "_" Thanks.  After searching the internet for a while, this is the first I've heard of "Utf8Encode".  This is exactly what I was looking for.