From: "Mike Lischke" Subject: Re: how to use MultiByteToWideChar to conver a string to unicode Date: 12 May 2000 00:00:00 GMT Message-ID: <8fhg4p$q6m1@bornews.borland.com> References: <8fh7pg$mn27@bornews.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.delphi.winapi "mayh" schrieb im Newsbeitrag news:8fh7pg$mn27@bornews.borland.com... > help me > > who can tell me how to use it > > to read a string from a text file and convert it to unicode? A typical implementation is shown below: function StringToWideStringEx(const S: String; CodePage: Word): WideString; var L: Integer; begin L:= MultiByteToWideChar(CodePage, 0, PChar(S), -1, nil, 0); SetLength(Result, L-1); MultiByteToWideChar(CodePage, 0, PChar(S), -1, PWideChar(Result), L - 1); end; file://--------------------------------------------------------------------- ----------- function WideStringToStringEx(const WS: WideString; CodePage: Word): String; var L: Integer; begin L := WideCharToMultiByte(CodePage, 0, PWideChar(WS), -1, nil, 0, nil, nil); SetLength(Result, L-1); WideCharToMultiByte(CodePage, 0, PWideChar(WS), -1, PChar(Result), L - 1, nil, nil); end; file://--------------------------------------------------------------------- ----------- This code is part of my Unicode library at www.lischke-online.de/Unicode.html which is currently under preparation for becoming a part of the JEDI VCL (www.delphi-jedi.org). Ciao, Mike