[Lazarus] File functions in codetools FileProcs
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue Jul 13 16:32:56 CEST 2010
On Tue, 13 Jul 2010 16:06:39 +0200 (CEST)
Michael Van Canneyt <michael at freepascal.org> wrote:
>
>
> On Tue, 13 Jul 2010, Juha Manninen wrote:
>
> > Mattias Gaertner wrote:
> >> Uses section?
> >> Maybe you mean required package?
> >
> > Maybe. I have lazarus.lpi open and my mind is mixed up.
> >
> >
> >> BTW, unit FileUtil is one of the base units of the LCL, without
> >> widgetset dependencies. Using it in console applications is safe.
> >
> > Yes, after adding LCL dependency and NoGUI widgetset. Currently the converter
> > does not add LCL dependency for console apps. I will make it optional later.
> > Some developers considered NoGUI widgetset as a bad idea, as you remember.
It is, because you see no warning if you use widgetset functions,
that do not work.
But unit FileUtil and some other base units work widgetset independent.
They are more like FCL extensions but in a lazarus way of doing it.
> >> But when converting a console application it is not clear if
> >> UTF8 filenames is a good choice (IMO).
> >
> > Can you please explain. I don't know the details here. I thought file name
> > conversion is an OS related issue, not GUI related.
>
> It is GUI related.
> The lazarus GUI uses UTF-8, so when transferring a filename from a TFileNameEdit
> (or TOPenDialog) to a FileOpen() function, the conversion from UTF-8 to system
> encoding must be done.
>
> Console applications will normally not use UTF-8 in the first place, they
> will normally be using system encoding from the start, so it is a bad idea
> to insert conversion routines, since none is necessary to start with...
Yes, if you only target windows.
If you want to convert a delphi console program to let it run
under Linux or Mac, then you have to check all file functions. If you
use system encoding, widestring or utf8 depends depends heavily on the
code and there is no good general advice.
Mattias
More information about the Lazarus
mailing list