[fpc-pascal] Re: Converting StrLCopy to widestrings
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Sat Nov 17 11:59:42 CET 2007
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
FileNameBufferSize := FileNameBufferLen
else FileNameBufferSize := Length(FileNameWide);
Move(FileNameWide[1], FileNameWideBuffer^, FileNameBufferSize * 2);
end
else
StrLCopy(FileNameBuffer, PChar(UTF8ToAnsi(FileName)), FileNameBufferLen);
{$else}
StrLCopy(FileNameBuffer, PChar(FileName), FileNameBufferLen);
{$endif}
But still, the code would be much simpler and shorter if there were
PWideChar routines
--
Felipe Monteiro de Carvalho
More information about the fpc-pascal
mailing list