This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygwin_conv_ functions and character encoding


On Feb  5 16:47, Thomas Wolff wrote:
> The cygwin path conversion functions ignore the current locale;
> rather they seem to always use the locale environment set when the program
> was started, see test program convloc.c:
> [...]
> In sys_wcstombs in strfuncs.cc I see:
>   const char *charset = cygheap->locale.charset;
> which is set in internal_setlocale ()...
> 
> In fact, the situation can be fixed by adding after setlocale():
>   cygwin_internal(CW_INT_SETLOCALE);  // -> internal_setlocale();
> (cf. https://sourceware.org/ml/cygwin-developers/2010-02/msg00054.html)
> but I think those functions should use the proper locale implicitly;
> according to the generic description in
> http://linux.die.net/man/3/setlocale,
> LC_CTYPE affects ... conversion ... functions, in my opinion this would
> include cygwin-specific conversion functions as well as implicitly called
> conversion (see open() below).
> The same problem applies to the open() function (involving path conversion).
> The wide string function mbstowcs behaves as expected.

Path conversion is a problem when switching locales.  Typically
an application calls setlocale (LC_ALL, "") only and in that case the
conversion works as desired.  We could switch cygwin_path_conv as
you said, but I'm wondering what side-effects that may have.  See
the comment in internal_setlocale().

> The whole issue occurred to me while trying to work around a missing
> conversion functionality, just converting the pathname syntax between
> Unicode strings. The desired options would be like:
>   CCP_POSIX_W_TO_WIN_W,   /* from is wchar_t *posix, to is wchar_t *win32
> */
>   CCP_WIN_W_TO_POSIX_W,   /* from is wchar_t *win32, to is wchar_t *posix
> */

Those are not available because POSIX paths are always multibyte strings.
Patches welcome, though.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]