Re: [fpc-pascal] Converting StrLCopy to widestrings

2007-11-17 Thread Felipe Monteiro de Carvalho
On Nov 17, 2007 1:25 PM, Marc Weustink <[EMAIL PROTECTED]> wrote: > First question, why is the copying needed ? > Why isn'tlpStrFile := PWChar(FileNameWide); > simply enough ? > > IMO, you're copying way to much. That variable is only valid on the scope of the function, and we need something m

Re: [fpc-pascal] Converting StrLCopy to widestrings

2007-11-17 Thread Marc Weustink
Felipe Monteiro de Carvalho wrote: Hello, In a LCL code we have: var FileNameBuffer: PChar; FileNameWide: WideString; FileNameWideBuffer: PWideChar; FilterBuffer: WideString; begin {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then FileNameWideBuffer := AllocMem(FileNameBuffe

[fpc-pascal] Re: Converting StrLCopy to widestrings

2007-11-17 Thread Felipe Monteiro de Carvalho
I managed to get it working with: {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then begin FileNameWide := UTF8Decode(FileName); FillChar(FileNameWideBuffer^, FileNameBufferLen * 2 + 2, #0); if Length(FileNameWide) > FileNameBufferLen then FileNameBufferSi

[fpc-pascal] Converting StrLCopy to widestrings

2007-11-17 Thread Felipe Monteiro de Carvalho
Hello, In a LCL code we have: var FileNameBuffer: PChar; FileNameWide: WideString; FileNameWideBuffer: PWideChar; FilterBuffer: WideString; begin {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then FileNameWideBuffer := AllocMem(FileNameBufferLen * 2 + 2) else FileNameBuff