[fpc-devel] twide3.pp on windows

Yury Sidorov jura at cp-lab.com
Mon Jul 16 21:01:27 CEST 2007


From: "Daniël Mantione" <daniel.mantione at freepascal.org>
> Op Mon, 16 Jul 2007, schreef Yury Sidorov:
>
> > From: "Daniël Mantione" <daniel.mantione at freepascal.org>
> > > Op Mon, 16 Jul 2007, schreef Yury Sidorov:
> > >
> > > > The code page (locale) is set in Control Panel for whole user
> > > > session (or
> > > > whole system).
> > > > It is not possible to set utf8 as locale.
> > >
> > > I know. How do you set it to a specific locale for the current
> > > application?
> >
> > widestring to ansistring conversion is performed using 
> > WideCharToMultiByte.
> > Currently it is done using ANSI code page specified in Control 
> > Panel.
> > There is no per application code page setting in Windows.
>
> There must be, because the CRT unit currently seems to do such vodoo
> (which is questionable behaviour by the way).

Yes. It is possible to specify code pages for console, gui controls, 
etc. But application must do it in runtime.

> > > > We can create flag in System unit which control how
> > > > widestring<->ansistring
> > > > should be performed to enable utf8 on Windows.
> > >
> > > No, you cannot (at least not with full functionality), since 
> > > uppercasing
> > > and compare operations on UTF-8 ansistrings you need a Unicode 
> > > library,
> > > which Windows does only provide in UTF-16 flavour.
> >
> > WideCharToMultiByte can convert from widestring to utf8 if 
> > corresponding flag
> > is specified. This flag is available in Windows 98/Me, Windows NT 
> > 4.0 and
> > later.
> > MultiByteToWideChar do reverse conversion.
> >
> > This functions already used in System unit for Windows.
>
> Yes, but how would you implement ansiuppercase and friends when utf8 
> flag
> is set to true?

Oh, yes it will not work on Windows, because utf8 is not supported 
here.

Then, twide3.pp should be skipped on Windows, since it is not possible 
to do it in locale independant way.

Yury.



More information about the fpc-devel mailing list