Winapi character and string functions (14): chartooem, oemtochar

Source: Internet
Author: User
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.
 
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.