Version:0.9 StartHTML:0000000105 EndHTML:0000270065 StartFragment:0000000141 EndFragment:0000270029
Program ZEOS_TestDemoUC_Tester; //in progress ᛗᚨᛪᛒᛟᛪ

//////////////////////////////////////////////////////////////////////
//  Get several functions of ZEOS utilities to test  unicode     ☮ ✞ π 📌           //
//  #sign: User: DESKTOP-BTLKHKF: 17/01/2024 15:04:55 
//  Purpose: checks convert and SQL  controls  🤗 🤗  🤗  🤗  🤗                //
//  #path>ples\C:\maxbox\maxbox51\maXbox502\maxbox5\examples\2\maxbox5\examples\
//  2 func, 0 proc: Lines of Code #locs:90590590  แม็กซ์บ็อกซ์5 - マックスボックス5 - 😀😀 😎👮🤗
//////////////////////////////////////////////////////////////////////

{unit uPSI_ZSysUtils; }

//uPSI_uLkJSON.pas, uPSI_HotLog; IndyPac3}
//TODO: find an example for all functions
//TODO: Save image to webserver_file, turn procedure [DownloadJPEGTo..] to function
Const
   UrlGoogleQrCode= 'http://chart.apis.google.com/chart?chs=%dx%d&cht=qr&chld=%s&chl=%s';
   AFILENAME= 'mX3QRCode3.png';
   QDATA= 'this is maXland on a maXbox stream dream firebox';
  
type
  TQrImage_ErrCorrLevel=(L,M,Q,H);
var
  js:TlkJSONobject;
  xs:TlkJSONbase;
  ws: String;
  
// i improve test for version 0.94 - add random part to names of fields;
// it smaller decrease speed of generation, but much better for testing
// Leon, 27/03/2007
{.$define usefastmm}

procedure SIRegister_ZSysUtils_Demo;
var //lv: TTreeview;
     lv: TListView;
     Item: TListItem;
     mybuffer: TObject;
     mybuffer2: TStrings;
     bytebuffer: TDynBytearray;
     i: integer;
    findtext: string;
begin
 // CL.AddTypeS('TZListSortCompare', 'Function (Item1, Item2 : TObject): Integer');
  //SIRegister_TZSortedList(CL);
  //FirstDelimiter( const Delimiters, Str : string) : Integer');
  //LastDelimiter( const Delimiters, Str : string) : Integer');
 // MemLCompUnicode( P1, P2 : PWideChar; Len : Integer) : Boolean');
 // MemLCompAnsi( P1, P2 : PAnsiChar; Len : Integer) : Boolean');
  //StartsWith( const Str, SubStr : WideString) : Boolean;');
  //StartsWith1( const Str, SubStr : RawByteString) : Boolean;');
  //EndsWith( const Str, SubStr : WideString) : Boolean;');
  //EndsWith1( const Str, SubStr : RawByteString) : Boolean;');
  //SQLStrToFloatDef( Str : RawByteString; Def : Extended) : Extended;');
  //SQLStrToFloatDef1( Str : String; Def : Extended) : Extended;');
  //SQLStrToFloat( const Str : AnsiString) : Extended');
 // BufferToStr( Buffer : PWideChar; Length : LongInt) : string;');
 // BufferToStr1( Buffer : PAnsiChar; Length : LongInt) : string;');
   
   mybuffer2
:= TStringlist.create;
   mybuffer2.text:='this is text trex';
   findtext:= 'A this is text trex';
   //bytebuffer:= BufferToBytes(TObject(findtext), length(findtext));
   
   bytebuffer
:= BufferToBytes(mybuffer2, length(mybuffer2.text));
   for i:= 0 to length(bytebuffer)-1 do 
    write
(inttoStr(bytebuffer[i])+' ');
   //writeln('StrToBoolEx '+( Str : string) : Boolean');
   writeln('BoolToStrEx  '+BoolToStrEx(true));
  if IsIpAddr('192.168.117.4') then writeln('is IP Addr');
  //SplitString( const Str, Delimiters : string) : TStrings');
 //PutSplitString( List : TStrings; const Str, Delimiters : string)');
 //AppendSplitString( List : TStrings; const Str, Delimiters : string)');
  //ComposeString( List : TStrings; const Delimiter : string) : string');
  writeln('FloatToSQLStr '+FloatToSQLStr(345.567));
 //PutSplitStringEx( List : TStrings; const Str, Delimiter : string)');
  //SplitStringEx( const Str, Delimiter : string) : TStrings');
 //AppendSplitStringEx( List : TStrings; const Str, Delimiter : string)');
  //BytesToStr( const Value : TByteDynArray) : AnsiString');
  //StrToBytes( const Value : AnsiString) : TByteDynArray;');
  {StrToBytes1( const Value : UTF8String) : TByteDynArray;');
  StrToBytes2( const Value : RawByteString) : TByteDynArray;');
  StrToBytes3( const Value : WideString) : TByteDynArray;');
  StrToBytes4( const Value : UnicodeString) : TByteDynArray;');}
  //BytesToVar( const Value : TByteDynArray) : Variant');
  //VarToBytes( const Value : Variant) : TByteDynArray');
  //AnsiSQLDateToDateTime( const Value : string) : TDateTime');
  //TimestampStrToDateTime( const Value : string) : TDateTime');
  //DateTimeToAnsiSQLDate( Value : TDateTime; WithMMSec : Boolean) : string');
  //EncodeCString( const Value : string) : string');
  //DecodeCString( const Value : string) : string');
   writeln('zReplaceChar '+zReplaceChar('m','o', 'this is maxbox'));
   writeln('zReplaceChar '+zReplaceChar('x','n', 'this is maxbox'));
 
  
//MemPas( Buffer : PChar; Length : LongInt) : string');
 //DecodeSQLVersioning( const FullVersion : Integer; out MajorVersion : Integer; out MinorVersion : Integer; out SubVersion : Integer)');
  //EncodeSQLVersioning( const MajorVersion : Integer; const MinorVersion : Integer; const SubVersion : Integer) : Integer');
  //FormatSQLVersion( const SQLVersion : Integer) : String');
  {ZStrToFloat( Value : AnsiChar) : Extended;');
  ZStrToFloat1( Value : AnsiString) : Extended;');
 ZSetString( const Src : AnsiChar; var Dest : AnsiString);');
 ZSetString1( const Src : AnsiChar; const Len : Cardinal; var Dest : AnsiString);');
 ZSetString2( const Src : AnsiChar; var Dest : UTF8String);');
 ZSetString3( const Src : AnsiChar; const Len : Cardinal; var Dest : UTF8String);');
 ZSetString4( const Src : AnsiChar; const Len : Cardinal; var Dest : WideString);');
 ZSetString5( const Src : AnsiChar; var Dest : RawByteString);');
 ZSetString6( const Src : AnsiChar; const Len : Cardinal; var Dest : RawByteString);');}
 //getdiskspace2
  //item := lv.GetItemAt(X, Y);
   //Findtext:= lv.Items.item[4].SubItems[1]; //'nd.';
   //Findtext:= lv.Items.item[lv.ItemIndex].SubItems[1]; //'nd.';
   //Findtext:= lv.Items.item[lv.ItemIndex].text; //'nd.';
   
   writeln
('😀😀 😎👮🤗');
end;
function MaxChoice (C1, C2, C3: integer): integer;
begin
  Result:= C1;
  if C2 > Result then Result:= C2;
  if C3 > Result then Result:= C3;
end;
function WordSim (const S1, S2: String): integer; //overload;
//Case-sensitive!
var i, l1, l2, minL: integer;
begin
  l1:= length(S1);
  l2:= length(S2);
  Result:= l1-l2;
  if Result > 0 then Result:= -Result;
  if (S1='') or (S2='') then exit;
  minL:= l1;
  if l2 < l1 then minL:= l2;
  for i := 1 to minL do if S1[i]<>S2[i] then dec(Result);
end;
function GapChars (const S: String; GapChar: Char): String;
  var i: integer;
  begin
    synassert (length(S)>0);
    Result:='';
    for i := 0 to length(S) - 1 do Result:=Result + GapChar;
  end;
procedure AlignWordsNW (const A, B: Array of String; GapChar: Char; const Delimiter: ShortString; GapPenalty: integer; out AlignmentA, AlignmentB: string);
// Needleman-Wunsch alignment
// GapPenalty should be a negative value!
var
  F: array of array of integer;
  i, j,
  Choice1, Choice2, Choice3,
  Score, ScoreDiag, ScoreUp, ScoreLeft :integer;
  {function GapChars (const S: String): String;
  var i: integer;
  begin
    assert (length(S)>0);
    Result:='';
    for i := 0 to length(S) - 1 do Result:=Result + GapChar;
  end;  }
begin
  //SetLength2Array (F, length(A)+1, length(B)+1);
  //SetArrayLength2Int2(arr: T2IntArray; asize1, asize2: Int);
(*  for i := 0 to length(A) do F[i,0]:= GapPenaltyi;
  for j := 0 to length(B) do F[0,j]:= GapPenaltyj;
  for i:=1 to length(A) do begin
    for j:= 1 to length(B) do begin
      Choice1:= F[i-1,j-1] + WordSim(A[i-1], B[j-1]);
      Choice2:= F[i-1, j] + GapPenalty;
      Choice3:= F[i, j-1] + GapPenalty;
      F[i,j]:= maxChoice (Choice1, Choice2, Choice3);
    end;
  end;
  AlignmentA:= '';
  AlignmentB:= '';
  i:= length(A);
  j:= length(B);
  while (i > 0) and (j > 0) do begin
    Score := F[i,j];
    ScoreDiag:= F[i-1,j-1];
    ScoreUp:= F[i,j-1];
    ScoreLeft:= F[i-1,j];
    if Score = ScoreDiag + WordSim(A[i-1], B[j-1]) then begin
      AlignmentA:= A[i-1] + Delimiter + AlignmentA;
      AlignmentB:= B[j-1] + Delimiter + AlignmentB;
      dec (i);
      dec (j);
    end else if Score = ScoreLeft + GapPenalty then begin
      AlignmentA:= A[i-1] + Delimiter + AlignmentA;
      AlignmentB:= GapChars (A[i-1]) + Delimiter + AlignmentB;
      dec(i);
    end else begin
      assert (Score = ScoreUp + GapPenalty);
      AlignmentA:= GapChars(B[j-1]) + Delimiter + AlignmentA;
      AlignmentB:= B[j-1] + Delimiter + AlignmentB;
      dec (j);
    end;
  end;
  while (i > 0) do begin
    AlignmentA:= A[i-1] + Delimiter + AlignmentA;
    AlignmentB:= GapChars(A[i-1]) + Delimiter + AlignmentB;
    dec(i);
  end;
  while (j > 0) do begin
    AlignmentA:= GapChars(B[j-1]) + Delimiter + AlignmentA;
    AlignmentB:= B[j-1] + Delimiter + AlignmentB;
    dec(j);
  end; *)
end;
function DownloadJPGToBitmap(const URL : string; ABitmap: TBitmap): Boolean;
var
  idHttp: TIdHTTP;
  ImgStream: TMemoryStream;
  JpgImage: TJPEGImage;
begin
  Result:= False;
  ImgStream:= TMemoryStream.Create;
  try
    idHttp:= TIdHTTP.Create(nil);
    try
    idHttp.Request.UserAgent:= 'maXbox5 compatible';
      idHttp.Get1(URL, ImgStream);
    finally
      idHttp.Free;
    end;
    ImgStream.Position:= 0;
    JpgImage:= TJPEGImage.Create;
    try
      JpgImage.LoadFromStream(ImgStream);
      ABitmap.Assign(JpgImage);
    finally
      Result:= True;
      JpgImage.Free;
    end;
  finally
    ImgStream.Free;
  end;
end;
procedure TForm1convertbuttonclick(Sender: TObject);
var
  use_st,
  s, s2, s3 : string;
  b, qt : boolean;   idDecoderMime1: TidDecoderMime;  
  
//idDecoderQuotedPrintable1: TidDecoderQuotedPrintable;
begin
  s := Memo1.lines[0];
  use_st := '?=';
  if pos('=?utf-8?', lowercase(s)) > 0 then  begin
    s2 := stringreplace(s, '=?utf-8?', '', [rfReplaceAll, rfIgnoreCase]);
    if pos('b?', lowercase(s2)) > 0 then begin
      s2 := stringreplace(s2, 'b?', '', [rfReplaceAll, rfIgnoreCase]);
      b := True;
      use_st := '=?=';
    end
    else if pos('q?', lowercase(s2)) > 0 then begin
      s2 := stringreplace(s2, 'q?', '', [rfReplaceAll, rfIgnoreCase]);
      qt := True;
    end;
  end else
    s2 := s;
  if pos(use_st, s2) > 0 then
    s2 := stringreplace(s2, use_st, '', [rfReplaceAll, rfIgnoreCase]);
  if q then
    //s3 := idDecoderQuotedPrintable1.decodestring(s2)
  else if b then
    s3 := idDecoderMime1.decodeString(s2)
  else
    s3 := s2;
  memo2.lines.clear;
  memo2.lines.add(s3);
end;
var  FStartChar, FEndChar: Integer;
procedure TMemoUnderline(StartLine, StartChar, EndLine, EndChar: Integer);
begin
  FStartChar := SendMessage(application.Handle, EM_LINEINDEX, StartLine, 0) + StartChar;
  FEndChar := SendMessage(application.Handle, EM_LINEINDEX, EndLine, 0) + EndChar;
  memo2.Invalidate;
end;
procedure TForm1Button2Click(Sender: TObject);
var
  i: Integer;
  Line: string;
  zoznam: TStringList;
begin
  zoznam := TStringList.Create;
  try
    //zoznam.Assign(Memo2.lines);  //zoznam.text:= memo1.text;
    for i := 0 to zoznam.Count-1 do begin
      Line := zoznam.Strings[i]; // or: Line := zoznam[i];
      //...
      zoznam.savetofile(exepath+'examples\unicodetestF.txt');
    end;
  finally
    zoznam.Free;
  end;
end;
procedure processAssign (l:tStrings);
var temp: tStringList;
: integer;
begin
Temp := tStringList.create;
try
writeln(objtostr(l));
writeln(objtostr(temp));
Temp.assign(l);  // ------ this gives an exception !!!
l.clear;
for I := 0 to temp.count-1 do begin
l.add(temp[I]); // just to do something
l.add(temp[I]);
end;
finally
temp.free;
end;
end;
procedure DrawLine(First, Last: Integer);
  var
    LineHeight: Integer;
    Pt1, Pt2: TSmallPoint;
    DC: HDC;
    aRect: TRect;
    ClipRgn: HRGN;   amemo: TMemo;  form1: Tform;
  begin
    // font height approximation (compensate 1px for internal leading)
    LineHeight := Absint(amemo.Font.Height) - Absint(amemo.Font.Height) div amemo.Font.Height;
    // get logical top-left coordinates for line bound characters
    //(Pt1) := SendMessage(form1.Handle, EM_POSFROMCHAR, First, 0);
    //Integer(Pt2) := SendMessage(Handle, EM_POSFROMCHAR, Last, 0);
    DC := GetDC(form1.Handle);
    // clip to not to draw to non-text area (internal margins)
    //SendMessage(form1.Handle, EM_GETRECT, 0, Integer(@aRect));
    ClipRgn := CreateRectRgn(aRect.Left, aRect.Top, aRect.Right, aRect.Bottom);
    SelectClipRgn(DC, ClipRgn);
    DeleteObject(ClipRgn); // done with region
    // set pen color to red and draw line
    SelectObject(DC, GetStockObject(DC_PEN));
    SetDCPenColor(DC, RGB(255, 0 ,0));
    //MoveToEx(DC, Pt1.x, Pt1.y + LineHeight, nil);
    LineTo(DC, Pt2.x, Pt2.+ LineHeight);
    ReleaseDC(form1.Handle, DC); // done with dc
  end;
  
  
function LoadStringW(): WideString;
      var
      Str, s1: String;  awid: widestring;
      aLength: Integer;
      begin
      Str := 'Initial Wide value';
      S1 := 'Ĥà̲V̂e' 
      SetLength
(Str, 30);
      awid:= str;
      awid:= 'seconde wide';
      str:= awid;
      writeln('refcnt '+itoa(StringRefCount(Str)));
      writeln('refcnt '+itoa(StringRefCount(awid)));
      writeln('refcnt '+itoa(StrRefCount(Str)));
      writeln('refcnt '+itoa(StrRefCount(awid)));
      //StrRefCount( const S : Ansistr) : Longint
      //aLength := GetStringW(Str); // ** ALTERS 'Str' **
      alength:= 50;
      SetLength(Str, aLength);
      Result := Str; // Str == 'New Wide value'
      writeln('uc len: '+itoa(len(s1)));
      {If I call length() on the Unicode string S := 'Ĥà̲V̂e' in Delphi, I will get back, 8.
This is because the lengths of the individual characters [Ĥ],[à̲],[V̂], and [e] are 2, 3, 2, 
and 1 respectively. This is because Ĥ has a surrogate, à̲ has two additional surrogates, 
V̂ has a surrogate and e has no surrogates.  }
      //GetFirstCodepointSize
   end;
   
 
procedure Copy_Utf16Test;
    var s0,s1 : string;        //$D80C$DC00
        ii    : integer;
    begin
      s0 := #$61#$13000#$63; //mem dump of s0: $61 $00 $0C $D8 $00 $DC $63 $00
      ii := length(s0);      //sets ii=4 (bytes)
      s1 := copy(s0,1,1);    //'a'
      s1 := copy(s0,2,1);    //#$D80C surrogate pair member; no corresponding named code-point
      s1 := copy(s0,3,1);    //#$DC00 surrogate pair member; no corresponding named code-point
      s1 := copy(s0,4,1);    //'c' first+last results sensible codepage CP_UNICODE (1200)
    end;  

//TODO:#1 Returns the QR Code direct of the last modification of the given File
const
  U_nbsp = $00A0;
  U_7 = $0037;

 var image2: TImage;
    z,x,y: smallint;     am: TImeMode;  mem1: TSynMemo;  mem2: TSynEdit;
     Line, S: string;  achr: char; awid: widechar;
   original, owide: WideString;
  ast: AnsiString;  
begin   //@main
  Writeln(datetimetostr(FileTimeGMT(exepath+'maxbox5.exe')));
  //call of the script
  //GetQrCodeIndy(150,150,'Q',ExePath+AFILENAME, QData);
  //call of the Lib
  //GetQrCode2(150,150,'Q',QDATA, ExePath+AFILENAME);
  //http://entwickler-konferenz.de/
  //http://www.softwareschule.ch/images/Ekon17_2013.jpg
  
  
//SIRegister_ZSysUtils_Demo;
  image2:= TImage.create(self); 
  
//Exception: Socket Error # 11001 Host not found. at 838.304
  if isInternetConnected then
    DownloadJPGToBitmap('http://www.softwareschule.ch/images/Ekon17_2013.jpg',
                              Image2.Picture.Bitmap);
    
   
{ with TCustomDrawForm.create(self) do begin
       width:=820;
       height:=820;
       image1.height:= 600; //add properties
       image1.picture.bitmap:= image2.picture.bitmap;
       //SelectionBackground1Click(self)
       //CustomDraw1Click(self);  
       //Selection1Click(self);
       Background1.click;
       bitmap1.click;
       Tile1.click;
       Showmodal;           //add methods
       Free;                
     end;
    }
    
    writeln
(itoa(gcd(4,6)));
    
   
//if IsTCPPortOpen(80,'192.168.1.53') then
   PrintF('gcd %.12f  ',[4*6*0.687876]);
      if IsTCPPortOpen(80,getIP(getHostName)) then
       writeln('Port 80 Open Started') else 
       writeln
('Port not open');
   maxCalcF('SQRT(PI)');
   //PrintF('gcd %f * lcm %f = %f ',[gcd(4,6), lcm(4,6), 4*6]);
     //SetAlias(Alias, aAliasDir);
     //SetBde('\DRIVERS\PARADOX\INIT','NET DIR',aNetDir);
     //SetBde('\SYSTEM\INIT','LOCAL SHARE','TRUE');
    //JSONTest;
    //hexofsha1 
    writeln(sha1tohex('this is fake'))
    writeln(sha1tohex('this is fake2'))
    writeln(sha1tohex('fake'))
    
    writeln
(floattostrF(1200.576878,fffixed,8,2))
    
    fmtstr
(sr,'%8s',[floattostr(1290456.586867584743)])
    writeln(sr)
    x:=1; y:=2; z:=3;
    writeln(botostr(not((x>=y)and(x>=z))and not((y>=x)and(y>=z))));
    //de morgan
    writeln(botostr(((x<y)or(x<z))and((y<x)or(y<z))));
     // memo1.lines.savetofile(exepath+'examples\412_dobble_python1UC22.txt');
       //memo1.lines.savetofile(scriptname);
       
       
       
//memo2.imemode
         writeln(utf8encode('😀😀 😎👮🤗'));
       memo2.lines.savetofile('examples/412_Zeosutils_sha64_uc2.txtOutput2.txt')
        Savestringtofile(exepath+'examples\unicodetest1.txt',utf8encode('㼿㼿㼠㼿㼿?53ꏰ檩ȃ'));  
      savestring
(exepath+'examples\unicodetest2.txt',utf8decode('😀😀 😎👮🤗'));  
        writeln
(utf8decode(LoadStringfromFile( exepath+'examples\unicodetest2.txt')))
         writeln(utf8decode(LoadFile( exepath+'examples\unicodetest1.txt')))
         
      mem1
:= TSynMemo.create(self);   
      mem1
.lines.add(utf8encode('😀😀 😎👮🤗'));
      mem1.lines.add(utf8encode('㼿㼿㼠㼿㼿?53ꏰ檩ȃ'));
      //mem1.text:= '㼿㼿㼠㼿㼿?53ꏰ檩ȃ';
      mem1.lines.savetofile( exepath+'examples\unicodetestA.txt');
      memo2.lines.add(mem1.text)
      mem1.free;
      
      mem2
:= TSynEdit.create(self);   
      
//mem2.assign(memo1);
      mem2.lines.add(utf8encode('😀😀 😎👮🤗'));
      mem2.lines.add(utf8encode('㼿㼿㼠㼿㼿?53ꏰ檩ȃ'));
      //mem1.text:= '㼿㼿㼠㼿㼿?53ꏰ檩ȃ';
      mem2.lines.savetofile( exepath+'examples\unicodetestC.txt');
      memo2.lines.add(mem2.text)
      mem2.free;
      
      
//line:= Memo1.Lines.Strings[304]; // or Line := Memo1.Lines[i];
      line:= Memo1.Lines[356]; // or Line := Memo1.Lines[i];
      writeln(line)
   //😀😀 😎👮🤗 㼿㼿㼠㼿㼿?53ꏰ檩ȃ
      
      savestring
(exepath+'examples\unicodetestD.txt',utf8encode(Memo1.Lines[356]));
      writeln(Memo1.Lines[366])
      //memo1.lines.savetofile( exepath+'examples\unicodetestB.txt');
      savestring(exepath+'examples\unicodetestE.txt',
              utf8encode(Memo1.Lines[366]+CRLF+Memo1.Lines[356]));
              
      TForm1Button2Click
(self);
      
      processAssign 
(TStringlist.create);   
      writelnuc
(utf8encode('😀😀 😎👮🤗'));   
      writeln
((#$00A9));// +utf8encode('😀😀 😎👮🤗 ☘️'));
      writeln((#$6211));
      //7/https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
      writeln((#$2618 + #$00c3 + #$00a0));
      writeln((#$1F60E));
      
      S
:= 'abcd' + Chr(U_nbsp) + Chr(U_7)+ #$1F604 + utf8encode(#$1F3A4) + #$21A9;
    //  showmessagebig(S);
      writeln(inttohex(ord('ç'),2));
      writeln(Chr($E7));
       //memo1.DoCopyToClipboard(Chr($E7));;
      //memo1.DoCopyToClipboard('(◍•ᴗ•◍) :heart:😀😀 😎👮🤗 ☘️ 🐞🌈');;
      SetClipboardWideText(' AText : string) 😀😀 😎👮🤗 ☘️ ✋🏻');
      //???? ?????? ??
    CopyHTMLToClipBoard('html AText : string) 😀😀 😎👮🤗 ☘️', '📌 🚀⋆༺𓆩☠︎𓆪༻⋆');  
    
      writelnuc
('᛭ᛪᛥᛔᛗ')
      //UTF8ToUTF16
      
      
//ᛗᛞЖ😀 😊
      writeln((#$16D7+#$16DE+#$0416+#$D83D+#$DE00))   //(5854)))
      
      writeln
(HexToBin2('0416'));  //00000100 00010110
      //Func HexCodePointToInt( const c :Card) : Int;
      writeln(inttostr64(HexCodePointToInt($0416)));
      writeln(itoa(HexToInt('D80C')))
      
      
//M->e, X->g
      writelnuc('maXbox'+#+'ᛗᚨᛪᛒᛟᛪ');
      writeln((#$16D7+#$16A8+#$16EA+#$16D2+#$16DF+#$16EA))        //U+16A8 (5800)
      
      
//U+16D7 (5847Ж)
      
       writelnuc
(itoa(ord('ᛗ')));
        writelnuc(itoa(ord('M')));
         writelnuc(itoa(ord('ᚨ')));
         
       original
:= '😊';
       ast:= 'ᛗ';  
       writeln
(utf8encode(original));
       writeln(utf8decode('㼿'));
       // writelnuc(itoa(ord('😊.  n .')));
      
    writeln
(ParseJsonvalue('{"official":"Swiss\u0020Confederation","common":"Switzerland"}'));
   // writeln(JSONUnescape('{"official":"Swiss\u0020Confederation","common":"Switzerland"}',#1310));
    owide:= LoadStringW();
    original := owide;
    ast:= owide;
    writeln('refcnt '+itoa(StringRefCount(owide)));
    writeln('refcnt '+itoa(StrRefCount(owide)));
    writeln('refcnt '+itoa(StringRefCount2(owide)));
    writeln(botostr(IsVariantNullOrEmpty(line)));
    writeln(botostr(IsVariantNullOrEmpty(owide)));
    original:= '😊'; ast:= '😊'; owide:= 'ጄ😊🙏🏻🚀𓁋';  
            
       writeln
(utf8encode(original+'  '+ast+ '  '+owide));
       //[unassigned: U+12FF3–U+12FFF]   
       //https://en.wiktionary.org/wiki/%F0%93%80%80 𓀀
       writeln(#$61#+#$1300+#$63);
       writeln(#$61#$D80C#$DC00#$63);
       writelnuc('transfert to utf16-hex: '#$D80C#$DC00);   //writeln(#$13000);
       writeln(#$F093#$8080); 
       showmessagebig
('hieroglyph'#$D80C#$DC00);
       
     writeln
(GetElementAtIndex('📌𓀀✝︎☨†😊𐐘💥╾━╤デ╦︻ඞා',1));  
     write
((#$270B#$D83C#$DFFB));
    write((#$D83D#$De4F#$D83C#$DFFb));  
    writ
('len of: '+itoa(len('🌈🙏🏻🔭')));
    awid:= 'h'; //'📌';
    awid:= 'ጄ'; //'📌';
    writ(itoa(len(awid)));
         
End.  

doc
:  https://stackoverflow.com/questions/21707127/delphi-7-how-to-copy-non-latin-text-to-clipboard-convert-to-unicode
 https://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate3/EN/html/delphivclwin32/StdCtrls_TMemo_ImeMode.html
       ref:   https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
  https://de.wikipedia.org/wiki/Unicodeblock_Runen 
  
  https
://emojidb.org/rocket-emojis
  https://www.fileformat.info/info/charset/UTF-8/list.htm?start=50174
  
  https
://stackoverflow.com/questions/25755822/how-manipulate-substrings-and-not-subarrays-of-unicodestring
  
  Why we cannot use single 
"\u" to represent smiley within a string? Because when \u escape was designed, all unicode chars 
  could be represented by 
2 bytes or 4 hexadecimal digits. So there are always 4 hexadecimal digits after \in a java string literal.
   To represent a larger value of Unicode you need a larger hexadecimal number but that will 
  break existing java strings
. So there java uses same approach as utf-16 representation.   
  
As an example, the letter A is represented in unicode as U+0041 and in ansi as just 41. So converting that would be pretty simple, 
  but you must find 
out how the unicode character is encoded. The most common are UTF-16 and UTF-8. UTF 16, is basically two bytes 
  per character
, but even that is an oversimplification, as a character may have more bytes. UTF-8 sounds as if it means 1 byte per 
  character but can be 
2 or 3. To further complicate matters, UTF-16 can be little endian or big endian. (U+0041 or U+4100).
Where your question makes no sense is if you wanted to for example convert the arabic letter ain U+0639 to ansi on an English locale. You can't.
In general, character set of hundreds thousands entries cannot be converted to character set of 127 entries 
without some loss 
of information or encoding scheme.
If so, then you can use the Ord standard function to get the Unicode code-point value of whatever Unicode character you have.
  
  
var
  original: WideString;
  s: AnsiString;
begin
  s := AnsiString(original); 
  
  The script engine does seem 
to be able to handle "WideStrings" correctly even though they are handled as Variant type. Function 
  calls seems 
to work as well. With both Unicode and ANSI data.
Most functions available through the script engine can only handle ANSI or Unicode (UCS-2). The functions in the Application 
and Document object can handle ANSI and Unicode (UTF-16).
  - `15.0` - RAD Studio XE7
  
- `16.0` - RAD Studio XE8
  
- `17.0` - RAD Studio 10.0 Seattle
  
- `18.0` - RAD Studio 10.1 Berlin
  
- `19.0` - RAD Studio 10.2 Tokyo
  
- `20.0` - RAD Studio 10.3 Rio
  
- `21.0` - RAD Studio 10.4 Sydney
  
- `22.0` - RAD Studio 11 Alexandria
  
- `23.0` - RAD Studio 12 Athens
       
 opening secret doors
. Some examples of riddles are:
Finding the code to open a chest that contains a key to another room.
Using a map and a compass to locate a hidden arrow in the wall.
Deciphering a message written in runes that reveals the location of Robins sword.
Shooting an arrow at a target that triggers a mechanism to open a door.
 
 
procedure SetClipboardText(const Text: WideString);
var
  Count: Integer;
  Handle: HGLOBAL;
  Ptr: Pointer;
begin
  Count := (Length(Text)+1)*SizeOf(WideChar);
  Handle := GlobalAlloc(GMEM_MOVEABLE, Count);
  Try
    Win32Check(Handle<>0);
    Ptr := GlobalLock(Handle);
    Win32Check(Assigned(Ptr));
    Move(PWideChar(Text)^, Ptr^, Count);
    GlobalUnlock(Handle);
    Clipboard.SetAsHandle(CF_UNICODETEXT, Handle);
  Except
    GlobalFree(Handle);
    raise;
  End;
end;      
       
procedure TFrm.FormCreate(Sender: TObject);
begin
  TabEmoj.Text:=#$1F604;
  KeyEmojisActivator.Text:=#$1F604;
  Attachbutton.Text:=#$1F4CE;
   VideoAudiobutton.Text:=#$1F3A5;  /// MIC = #$1F3A4;
   EnterButton.Text:=#$21A9;
end;  
(*----------------------------------------------------------------------------*)
procedure SIRegister_TlkJSONobject(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TlkJSONcustomlist', 'TlkJSONobject') do
  with CL.AddClassN(CL.FindClass('TlkJSONcustomlist'),'TlkJSONobject') do begin
    RegisterProperty('UseHash', 'Boolean', iptr);
    RegisterProperty('HashTable', 'TlkHashTable', iptr);
    RegisterProperty('HashTable', 'TlkBalTree', iptr);
    RegisterMethod('Function Add6(const aname:WideString; aobj: TlkJSONbase) : Integer;');
    RegisterMethod('Function OldGetField( nm : WideString) : TlkJSONbase');
    RegisterMethod('Procedure OldSetField(nm: WideString; const AValue : TlkJSONbase)');
    RegisterMethod('Function Add7(const aname:WideString; aboolean: Boolean) : Integer;');
    RegisterMethod('Function Add8( const aname : WideString; nmb : double) : Integer;');
    RegisterMethod('Function Add9( const aname : WideString; s : string) : Integer;');
    RegisterMethod('Function Add10(const aname:WideString;const ws:WideString):Integer;');
    RegisterMethod('Function Add11(const aname: WideString; inmb : Integer) : Integer;');
    RegisterMethod('Procedure Delete( idx : Integer)');
    RegisterMethod('Function IndexOfName( const aname : WideString) : Integer');
    RegisterMethod('Function IndexOfObject( aobj : TlkJSONbase) : Integer');
    RegisterProperty('Field', 'TlkJSONbase WideString', iptrw);
    SetDefaultPropery('Field');
    RegisterMethod('Constructor Create( bUseHash : Boolean)');
    RegisterMethod('Function Generate( AUseHash : Boolean) : TlkJSONobject');
    RegisterMethod('Function SelfType : TlkJSONtypes');
    RegisterMethod('Function SelfTypeName : string');
    RegisterProperty('FieldByIndex', 'TlkJSONbase Integer', iptrw);
    RegisterProperty('NameOf', 'WideString Integer', iptr);
    RegisterMethod('Function getDouble( idx : Integer) : Double;');
    RegisterMethod('Function getInt( idx : Integer) : Integer;');
    RegisterMethod('Function getString( idx : Integer) : string;');
    RegisterMethod('Function getWideString( idx : Integer) : WideString;');
    RegisterMethod('Function getBoolean( idx : Integer) : Boolean;');
    RegisterMethod('Function getDouble1( nm : string) : Double;');
    RegisterMethod('Function getInt1( nm : string) : Integer;');
    RegisterMethod('Function getString1( nm : string) : string;');
    RegisterMethod('Function getWideString1( nm : string) : WideString;');
    RegisterMethod('Function getBoolean1( nm : string) : Boolean;');
  end;
end;
  myformtemplate
     
with TCustomDrawForm.create(self) do begin
       image1.height:= 600; //add properties
       SelectionBackground1Click(self)
       Drawing1Click(self)'
       showmodal;           //add methods
       free;                //free it
     end;
  
  myform 
In order to make your life easier, the unit HotLog.pas declares an instance of THotLog, and calls its constructor automatically, 
as soon as your programm is 
loaded 
(in fact, as soon as the HotLog 
unit's part of your programm is loaded).
This instance is called "hLog". It is the object instance you'll use to access HotLog.pas/ThotLog properties and routines.
All the following examples will allways use it. However, and as stated before, THotLog being an object, you can declare as many instances 
of it as you want.
// and the written result will be :
********************************************************************************
>>>>
 Start HotLogTest.exe  v 1.0.0.4                         2004-03-09 23:38:54
           From : C:\Program Files\Borland\Delphi9\Projects\HotLog\
           Prms : (No params)

(....)

<<<<
 Stop  HotLogTest.exe                                    2004-03-09 23:38:55
********************************************************************************

http://theroadtodelphi.wordpress.com/2010/12/06/generating-qr-codes-with-delphi/
Using the Google Chart Tools / Image Charts (aka Chart API) you can easily generate QR codes, this kind of images are a special type of 
two
-dimensional barcodes. 
They are also known 
as hardlinks or physical world hyperlinks.
The QR Codes store up to 4,296 alphanumeric characters of arbitrary text. QR codes can be read by an optical device with the appropriate software. 
Such devices range from dedicated QR code readers 
to mobile phones.

Using Delphi there are several ways you can generate QR codes - to encode any text (URL, phone number, simple message). QR Codes store up to 
4,296 alphanumeric 
characters 
of arbitrary text.
The 2D Barcode VCL components is a set of components designed for generating and printing barcode symbols in your Delphi or C++ Builder applications. 
Use the components 
set like any other VCL components.
J4L Components includes the QR-code implementation featuring: auto, byte, alpha, numeric and kanji encoding.
The Google Chart Tools (Chart API) also let you generate QR-code images using an HTTP POST or 

All 
do you need to generate a QrCode is make a get request to this URI

http
://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=M&chl=Go+Delphi+Go
uses
 PngImage,
 HTTPApp,
 WinInet;
 
type
TQrImage_ErrCorrLevel=(L,M,Q,H);
 
const
UrlGoogleQrCode='http://chart.apis.google.com/chart?chs=%dx%d&cht=qr&chld=%s&chl=%s';
QrImgCorrStr   : array [TQrImage_ErrCorrLevel] of string=('L','M','Q','H');
 
procedure WinInet_HttpGet(const Url: string;Stream:TStream);
const
BuffSize = 1024*1024;
var
  hInter   : HINTERNET;
  UrlHandle: HINTERNET;
  BytesRead: DWORD;
  Buffer   : Pointer;
begin
  hInter := InternetOpen('', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  if Assigned(hInter) then
  begin
    Stream.Seek(0,0);
    GetMem(Buffer,BuffSize);
    try
        UrlHandle := InternetOpenUrl(hInter, PChar(Url), nil, 0, INTERNET_FLAG_RELOAD, 0);
        if Assigned(UrlHandle) then
        begin
          repeat
            InternetReadFile(UrlHandle, Buffer, BuffSize, BytesRead);
            if BytesRead>0 then
             Stream.WriteBuffer(Buffer^,BytesRead);
          until BytesRead = 0;
          InternetCloseHandle(UrlHandle);
        end;
    finally
      FreeMem(Buffer);
    end;
    InternetCloseHandle(hInter);
  end
end
;
 
//this function return a Stream (PngImage inside) with a Qr code.
procedure GetQrCode(Width,Height:Word;Correction_Level:TQrImage_ErrCorrLevel;const Data:string;StreamImage : TMemoryStream);
Var
 EncodedURL  : string;
begin
  EncodedURL:=Format(UrlGoogleQrCode,[Width,Height,QrImgCorrStr[Correction_Level],HTTPEncode(Data)]);
  WinInet_HttpGet(EncodedURL,StreamImage);
end;

http://www.delphi-central.com/callback.aspx
 public
    { Public-Deklarationen }
    constructor Create(Owner:TComponent); override;
    destructor Destroy; override;
    procedure Assign(Source: TPersistent);override;
    procedure DrawBarcode(Canvas:TCanvas);
    procedure DrawText(Canvas:TCanvas);
    property CanvasHeight :Integer read GetCanvasHeight;
    property CanvasWidth :Integer read GetCanvasWidth;
  published
    { Published-Deklarationen }
   { Height of Barcode (Pixel)}
    property Height : integer read FHeight write SetHeight;
    property Text   : string read FText write SetText;
    property Top    : Integer read FTop write SetTop;
    property Left   : Integer read FLeft write SetLeft;
   { Width of the smallest line in a Barcode }
    property Modul  : integer read FModul  write SetModul;
    property Ratio  : Double read FRatio write SetRatio;
    property Typ    : TBarcodeType read FTyp write SetTyp default bcCode_2_5_interleaved;
   { build CheckSum ? }
    property Checksum:boolean read FCheckSum write SetCheckSum default FALSE;
    property CheckSumMethod:TCheckSumMethod read FCheckSumMethod write FCheckSumMethod default csmModulo10;
   { 0 - 360 degree }
    property Angle  :double read FAngle write SetAngle;
    property ShowText:TBarcodeOption read FShowText write SetShowText default bcoNone;
    property ShowTextFont: TFont read FShowTextFont write SetShowTextFont;
    property ShowTextPosition: TShowTextPosition read FShowTextPosition write SetShowTextPosition default stpTopLeft;
    property Width : integer read GetWidth write SetWidth stored False;
    property Color:TColor read FColor write FColor default clWhite;
    property ColorBar:TColor read FColorBar write FColorBar default clBlack;
      property OnChange:TNotifyEvent read FOnChange write FOnChange;
  end;
function CheckSumModulo10(const data:string):string;
function ConvertMmToPixelsX(const Value:Double):Integer;
function ConvertMmToPixelsY(const Value:Double):Integer;
function ConvertInchToPixelsX(const Value:Double):Integer;
function ConvertInchToPixelsY(const Value:Double):Integer;
  
procedure GetQrCodeImage(Width,Height: Word; Correct_Level: string;
           const Data:string; aimage: TImage; apath: string);
var
  encodedURL: string;
  idhttp: TIdHttp;// THTTPSend;
  pngStream: TMemoryStream;
begin
  encodedURL:= Format(UrlGoogleQrCode,[Width,Height, Correct_Level, HTTPEncode(Data)]);
  //WinInet_HttpGet(EncodedURL,StreamImage);
  idHTTP:= TIdHTTP.Create(NIL)
  pngStream:= TMemoryStream.create;
  with TLinearBitmap.Create do try
    idHTTP.Get1(EncodedURL, pngStream)
    pngStream.Position:= 0;
    LoadFromStream2(pngStream,'PNG');
    aImage.Picture:= NIL;
    AssignTo(aimage.picture.bitmap);
    SaveToFile(apath);
    //OpenDoc(apath);
  finally
    Dispose;
    Free;
    idHTTP.Free
    pngStream
.Free;
  end;
end;
procedure GetQrCode3(Width,Height: Word; Correct_Level: string;
           const Data:string; apath: string);
var
  encodedURL: string;
  idhttp: TIdHttp;// THTTPSend;
  png: TLinearBitmap;//TPNGObject;
  pngStream: TMemoryStream;
begin
  encodedURL:= Format(UrlGoogleQrCode,[Width,Height, Correct_Level, HTTPEncode(Data)]);
  //WinInet_HttpGet(EncodedURL,StreamImage);
  idHTTP:= TIdHTTP.Create(NIL)
  pngStream:= TMemoryStream.create;
  with TLinearBitmap.Create do try
    idHTTP.Get1(EncodedURL, pngStream)
    pngStream.Position:= 0;
    LoadFromStream2(pngStream,'PNG');
    //aImage.Picture:= NIL;
    //AssignTo(aimage.picture.bitmap);
    SaveToFile(apath);
    OpenDoc(apath);
  finally
    Dispose;
    Free;
    idHTTP.Free
    pngStream
.Free;
  end;
end;
//BDE Install Test
procedure TForm1.BtnSetupClick(Sender: TObject);
var aAliasDir, aNetDir:String;
begin
  Application.ProcessMessages;
  aAliasDir:=EditDataDir.Text;
  aNetDir:=EditNetDir.Text;
//  aAliasDir:='E:\SAS\Daten';
//  aNetFileDir:='E:\';
//  ShowMessage(ExpandUNCFileName(aAliasDir));
  if trim(aAliasDir)='' then raise Exception.Create('Geben Sie bitte das Datenverzeichnis an.');
 if trim(aNetDir)='' then raise Exception.Create('Geben Sie bitte das Netzverzeichnis an.');
  if not DirectoryExists(aAliasDir) then raise Exception.Create('Das Datenverzeichnis konnnte nicht gefunden werden.');
  if not DirectoryExists(aNetDir) then raise Exception.Create('Das Netzverzeichnis konnnte nicht gefunden werden.');
  try
     Screen.Cursor:=crHourGlass;
     SetAlias(Alias, aAliasDir);
     SetBde('\DRIVERS\PARADOX\INIT','NET DIR',aNetDir);
     SetBde('\SYSTEM\INIT','LOCAL SHARE','TRUE');
//     SetBde('\DRIVERS\PARADOX\TABLE CREATE','BLOCK SIZE','4096'); // Standard 2048 KB
//     SetBde('\DRIVERS\PARADOX\TABLE CREATE','LEVEL','7');
     SetBde('\DRIVERS\PARADOX\INIT','LANGDRIVER','ANSIINTL'); // ANSIINTL ist der Kurzname für Pdox ANSI Intl
     SetBde('\SYSTEM\INIT','LANGDRIVER','ANSIINTL');
     // soll angeblich die Performance verbessern
     SetBde('\System\Init','MAXFILEHANDLES','100'); // (Standard: 48)
     SetBde('\System\Init','MAXBUFSIZE','2048'); // Cachepuffer in KB (Standard: 2048 KB)
     SetBde('\System\Init','MINBUFSIZE','128');
     //SetBde('\System\Init','MEMSIZE','64'); // max. BDE-Speicher (Standard: 16 MB)
     //SetBde('\System\Init','SHAREDMEMSIZE','8192'); // Speicher (Standard: 2048 KB)
  finally
     Screen.Cursor:=crDefault;
  end;
  Close;
(*
  // Versionen der redirector-files testen (nur Win 95)
  if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then CheckRedirector;
  // Registry checken
  case Win32Platform of
    VER_PLATFORM_WIN32_WINDOWS: CheckWin95Registry;
    VER_PLATFORM_WIN32_NT:      CheckWinNTRegistry;
  end;
  // Neustart
  if RebootRequired then RestartDialog(0, nil, ew_RestartWindows);
*)
end;



    six spaces!
    Findtext:= lv.Items.item[lv.ItemIndex].SubItems[1]; //'End.';


procedure SIRegister_TCustomDrawForm(CL: TPSPascalCompiler);
begin
  //with RegClassS(CL,'TForm', 'TCustomDrawForm') do
  with CL.AddClassN(CL.FindClass('TForm'),'TCustomDrawForm') do
  begin
    RegisterProperty('TV', 'TTreeView', iptrw);
    RegisterProperty('ImageList', 'TImageList', iptrw);
    RegisterProperty('MainMenu1', 'TMainMenu', iptrw);
    RegisterProperty('Drawing1', 'TMenuItem', iptrw);
    RegisterProperty('Font1', 'TMenuItem', iptrw);
    RegisterProperty('Background1', 'TMenuItem', iptrw);
    RegisterProperty('Color1', 'TMenuItem', iptrw);
    RegisterProperty('Bitmap1', 'TMenuItem', iptrw);
    RegisterProperty('DefaultDrawing1', 'TMenuItem', iptrw);
    RegisterProperty('OnCustomDraw1', 'TMenuItem', iptrw);
    RegisterProperty('OnCustomDrawItem1', 'TMenuItem', iptrw);
    RegisterProperty('BrushStyle1', 'TMenuItem', iptrw);
    RegisterProperty('Solid1', 'TMenuItem', iptrw);
    RegisterProperty('Clear1', 'TMenuItem', iptrw);
    RegisterProperty('Horizontal1', 'TMenuItem', iptrw);
    RegisterProperty('Vertical1', 'TMenuItem', iptrw);
    RegisterProperty('FDiagonal1', 'TMenuItem', iptrw);
    RegisterProperty('BDiagonal1', 'TMenuItem', iptrw);
    RegisterProperty('Cross1', 'TMenuItem', iptrw);
    RegisterProperty('DiagCross1', 'TMenuItem', iptrw);
    RegisterProperty('File1', 'TMenuItem', iptrw);
    RegisterProperty('Exit1', 'TMenuItem', iptrw);
    RegisterProperty('N2', 'TMenuItem', iptrw);
    RegisterProperty('TVFontDialog', 'TFontDialog', iptrw);
    RegisterProperty('Tile1', 'TMenuItem', iptrw);
    RegisterProperty('Stretch1', 'TMenuItem', iptrw);
    RegisterProperty('None1', 'TMenuItem', iptrw);
    RegisterProperty('Selection1', 'TMenuItem', iptrw);
    RegisterProperty('SelectedFontDialog', 'TFontDialog', iptrw);
    RegisterProperty('BkgColorDialog', 'TColorDialog', iptrw);
    RegisterProperty('SelBkgColorDialog', 'TColorDialog', iptrw);
    RegisterProperty('SelectionBackground1', 'TMenuItem', iptrw);
    RegisterProperty('ButtonColor1', 'TMenuItem', iptrw);
    RegisterProperty('ButtonSize1', 'TMenuItem', iptrw);
    RegisterProperty('ButtonColorDialog', 'TColorDialog', iptrw);
    RegisterProperty('Image1', 'TImage', iptrw);
    RegisterProperty('TreeView1', 'TMenuItem', iptrw);
    RegisterProperty('Color2', 'TMenuItem', iptrw);
    RegisterProperty('TVColorDialog', 'TColorDialog', iptrw);
    RegisterProperty('CustomDraw1', 'TMenuItem', iptrw);
    RegisterProperty('Font2', 'TMenuItem', iptrw);
    RegisterMethod('Procedure FormCreate( Sender : TObject)');
    RegisterMethod('Procedure TVCustomDraw( Sender : TCustomTreeView; const ARect : TRect; var DefaultDraw : Boolean)');
    RegisterMethod('Procedure TVCustomDrawItem( Sender : TCustomTreeView; Node : TTreeNode; State : TCustomDrawState; var DefaultDraw : Boolean)');
    RegisterMethod('Procedure TVGetImageIndex( Sender : TObject; Node : TTreeNode)');
    RegisterMethod('Procedure TVGetSelectedIndex( Sender : TObject; Node : TTreeNode)');
    RegisterMethod('Procedure Exit1Click( Sender : TObject)');
    RegisterMethod('Procedure Selection1Click( Sender : TObject)');
    RegisterMethod('Procedure Color1Click( Sender : TObject)');
    RegisterMethod('Procedure SelectionBackground1Click( Sender : TObject)');
    RegisterMethod('Procedure Solid1Click( Sender : TObject)');
    RegisterMethod('Procedure None1Click( Sender : TObject)');
    RegisterMethod('Procedure OnCustomDraw1Click( Sender : TObject)');
    RegisterMethod('Procedure OnCustomDrawItem1Click( Sender : TObject)');
    RegisterMethod('Procedure TVExpanded( Sender : TObject; Node : TTreeNode)');
    RegisterMethod('Procedure ButtonColor1Click( Sender : TObject)');
    RegisterMethod('Procedure ButtonSize1Click( Sender : TObject)');
    RegisterMethod('Procedure Drawing1Click( Sender : TObject)');
    RegisterMethod('Procedure Color2Click( Sender : TObject)');
    RegisterMethod('Procedure CustomDraw1Click( Sender : TObject)');
    RegisterMethod('Procedure Font2Click( Sender : TObject)');
  end;
end;

{.$define usefastmm}
program test;
//{$APPTYPE CONSOLE}
uses
{$ifdef usefastmm}
  fastmm4,
{$endif}
  windows,
  SysUtils,
  uLkJSON in 'uLkJSON.pas';
var
  js:TlkJSONobject;
  xs:TlkJSONbase;
  i,j,k,l: Integer;
  ws: String;
begin
{$ifdef USE_D2009}
  ReportMemoryLeaksOnShutdown := True;
{$endif}
  Randomize;
  js := TlkJSONobject.Create(true);
//  js.HashTable.HashOf := js.HashTable.SimpleHashOf;
  k := GetTickCount;
// syntax of adding changed to version 0.95+
  for i := 0 to 50000 do
    begin
      l := random(9999999);
      ws := 'param'+inttostr(l);
      js.add(ws,ws);
      ws := 'int'+inttostr(l);
      js.add(ws,i);
    end;
  k := GetTickCount-k;
  writeln('records inserted:',js.count);
  writeln('time for insert:',k);
  writeln('hash table counters:');
  writeln(js.hashtable.counters);
  k := GetTickCount;
  ws := TlkJSON.GenerateText(js);
  writeln('text length:',length(ws));
  k := GetTickCount-k;
// free the object
  writeln('release memory...');
  js.Free;
//  js.Free;
  writeln('time for gentext:',k);
  k := GetTickCount;
  xs := TlkJSON.ParseText(ws);
  k := GetTickCount-k;
  writeln('time for parse:',k);
  writeln('approx speed of parse (th.bytes/sec):',length(ws) div k);
  writeln('press enter...');
  readln;
  writeln(ws);
  writeln('press enter...');
  readln;
// works in 0.94+ only!
  js := TlkJSONobject(xs);
  for i := 1 to 10 do
    begin
      writeln('field ',i,' is ',js.NameOf[i]);
      writeln('type of field ',i,' is ',js.FieldByIndex[i].SelfTypeName);
      writeln('value of field ',i,' is ',js.FieldByIndex[i].Value);
      writeln;
    end;
  writeln('release memory...');
  if assigned(xs) then FreeAndNil(xs);
//  js.Free;
//}
  writeln('press enter...');
  ws := '';
  readln;
end.
 mX5 executed: 28/11/2023 16:15:33  Runtime: 0:0:2.325  Memload: 69% use
 mX5 executed
: 28/11/2023 20:17:02  Runtime: 0:0:2.261  Memload: 74% use
    
    
To convert Unicode codepoints to UTF-8, you need to follow some rules based 
    
on the range of the codepoint. UTF-8 uses up to 
    
4 bytes to represent Unicode codepoints, and 
    each byte has a specific pattern 
of bits. 
    Here 
is a summary of the rules1:
If the codepoint is between 0x00000000 and 0x0000007F, use one byte with the pattern 0xxxxxxx, where xxxxxxx are the 7 bits of the codepoint.
If the codepoint is between 0x00000080 and 0x000007FF, use two bytes with the pattern 110xxxxx 10xxxxxx, where xxxxx are the first 5 bits of 
the codepoint
, and xxxxxx are the next 6 bits.
If the codepoint is between 0x00000800 and 0x0000FFFF, use three bytes with the pattern 1110xxxx 10xxxxxx 10xxxxxx, where xxxx are the first 
4 bits of the codepoint, and xxxxxx are the 
next 
6 bits, and so on.
If the codepoint is between 0x00010000 and 0x001FFFFF, use four bytes with the pattern 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx, where xxx are the 
first 
3 bits of the codepoint, and xxxxxx are the next 6 bits, and so on.
For example, if the codepoint is U+0041, which is the letter A, then it is in the first range, so we use one byte with the pattern 0xxxxxxx. T
he binary representation 
of U+0041 is 00000000 01000001, so we fill the 
7 bits of the pattern with the last 7 bits of the codepoint, and get 01000001. This is the UTF-8 encoding of U+0041.
If the codepoint is U+0416, which is the Cyrillic letter Ж, then it is in the second range, so we use two bytes with the pattern 110xxxxx 10xxxxxx. 
The binary representation 
of U+0416 is 00000100 00010110, 
so we fill the 
5 bits of the first byte with the first 5 bits of the codepoint, and the 6 bits of the second byte with the next 6 bits of the codepoint, 
and get 11000100 10000110. This is the UTF-8 encoding of U+0416.
If you want to see some code examples of how to convert Unicode codepoints to UTF-8 in different programming languages, you can check out these links:
Delphi
C
++
PHP
I hope this explanation helps you understand how 
to convert Unicode codepoints to UTF-8. ��

----
app_template_loaded_code----