[fpc-pascal] Unicode file routines proposal
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Mon Jun 30 14:00:32 CEST 2008
Hello,
There is already another thread about that, but the thread got too
long, and I would like to make a concrete proposal about unicode file
routines.
It looks simple to me, there are just 2 ways to go, either utf-8 or
utf-16. Correct me if I am wrong, but I beliave that FPC developers
prefer utf-16, so we can have a widestring version of every routine in
the RTL which involves filenames.
So let me start with a concrete example:
http://www.freepascal.org/docs-html/rtl/system/assign.html
We would need to add a:
procedure Assign(
var f: ;
const Name: widestring
);
Also for all this routines:
http://www.freepascal.org/docs-html/rtl/sysutils/filenameroutines.html
Under Windows it can be implemented like this with Windows 9x support:
procedure AnyFileRoutineInWin32(AFileName: widestring);
begin
if UnicodeEnabledOS then SomeWin32APIW()
else AnsiToWideString(SomeWin32ApiA())
end;
One can initialize UnicodeEnabledOS by reading the operating system
version and the operating system type NT/9x very easily.
Under Windows 9x we won't support true unicode filenames, but this
doesn't matter, because the operating system doesn't support them
anyway. The widestring routines will keep working under Windows 9x for
most code.
This method is used with great success in the LCL. Extended information here:
http://wiki.lazarus.freepascal.org/LCL_Unicode_Support#Guidelines
--
Felipe Monteiro de Carvalho
More information about the fpc-pascal
mailing list