The difference between chartooembuff and oemtocharbuff is that the former can specify the number of characters to be converted.
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; button3: tbutton; button4: tbutton; Procedure submit (Sender: tobject ); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.button1click (Sender: tobject); var Buf: pwidechar; ansibuf: array [0 .. 255] of ansichar; begin Buf: = 'delphi blog'; chartooem (BUF, ansibuf); showmessage (string (ansibuf )); {In case of Delphi blog} fillchar (ansibuf, length (ansibuf), #0); chartooembuff (BUF, ansibuf, 6); showmessage (string (ansibuf )); {de} end in case; Procedure tform1.button2click (Sender: tobject); var STR: string; P: pansichar; begin STR: = 'delphi blog in case '; P: = getmemory (256); chartooem (pchar (STR), P); showmessage (string (p); {in case of Delphi blog} freememory (p); P: = getmemory (256); chartooembuff (pchar (STR), P, 6); showmessage (string (p); {in case of De} freememory (p); end; procedure tform1.button3click (Sender: tobject); var ansibuf: pansichar; Buf: array [0 .. 255] of char; begin ansibuf: = 'delphi blog in case '; oemtochar (ansibuf, Buf); showmessage (string (BUF )); {In case of Delphi blog} fillchar (BUF, length (BUF), #0); oemtocharbuff (ansibuf, Buf, 6); showmessage (string (BUF )); {In case} end; Procedure tform1.button4click (Sender: tobject); var ansistr: ansistring; P: pchar; begin ansistr: = 'in case of Delphi blog'; P: = stralloc (256); oemtochar (pansichar (ansistr), P); showmessage (string (p); {in case of Delphi blog} strdispose (p); P: = stralloc (256); oemtocharbuff (pansichar (ansistr), P, 6); showmessage (string (p); {In case} strdispose (p); end.