[fpc-devel] Unicode support (yet again)

Luiz Americo Pereira Camara luizmed at oi.com.br
Fri Sep 16 19:24:30 CEST 2011


On 16/9/2011 14:03, Luiz Americo Pereira Camara wrote:
> On 16/9/2011 09:36, Marco van de Voort wrote:
>> In our previous episode, Luiz Americo Pereira Camara said:
>>> Take the example of FileExists:
>>>
>>> The current LCL implementation - the UTF8 ->  UTF16 conversion is done
>>> with the need of auxiliary code:
>> All the routines you name (fileexists, filegetattr etc) will become
>> rawbytestring and accept both utf8 and utf16, and then only in the
>> implementation figure out if conversion is necessary. (to the 
>> encoding of
>> the OS)
>>
>
> Better.

I took a look at the Delphi An Unicode document by Marco Cantu and a get 
doubt about the implementation with RawByteString:

Assume the implementation under windows of FileGetAttr:

with UnicodeString (there's no need to conversion - all good):

function FileGetAttr(const FileName: UnicodeString): Longint;
begin
   Result:=Integer(Windows.GetFileAttributesW(PWideChar(FileName)));
end;

with RawByteString (need the conversion - but how ?????):

function FileGetAttr(const FileName: RawByteString): Longint;
begin
   // how to convert?
   // UnicodeString(FileName) -> will not work because dont know if is 
was a UTF8 or UTF16 or whatever before passing as RawByteString 
parameter. SetCodePage will also not work.
   Result:=Integer(Windows.GetFileAttributesW(PWideChar(FileName)));
end;

Luiz



More information about the fpc-devel mailing list