[Lazarus] Help with basic pointer operations

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Mon Aug 22 17:08:28 CEST 2011



On Mon, 22 Aug 2011, Tommi Prami wrote:

> Hello,
>
> I kind of always try to stay away from the pointers, but now I maybe need to 
> use them...
>
> I think this is not correct yet (at least it does not to 100% what I like) :
>
> var
>  LSimpleStr     : string;
>  LTmpWStr      : array [0..250] of WideChar;
> ...
>  LSimpleStr := 'Some text';
>  mwStrToWide(LSimpleStr, LTmpWStr ,  250);
> ...
>
>
> procedure mwStrToWide(const AString: string; PWideString: PWideChar;
>  const ABufferLen: Integer);
> begin
>  FillChar(PWideString^, ABufferLen, 0);

At least this is wrong, since the buffer is 2*250 wide. 
FillChar assumes that 1 char = 1 byte.

Michael.




More information about the Lazarus mailing list