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]


On Dec  7 18:00, Bengt Larsson wrote:
> Corinna Vinschen wrote:
> >- cygwin_conv_path and cygwin_conv_path_list: In CCP_WIN_A_TO_POSIX and
> >  CCP_POSIX_TO_WIN_A conversions, use the current Windows ANSI or OEM
> >  charset, depending on the return value of AreFileApisANSI.  Up to Cygwin
> >  1.7.9, both conversions used the current Cygwin charset for the conversion.
> Is that the right thing to do? I have LANG=C.UTF-8. If I pass a
> Windows-style filename on the command line, it's passed as UTF-8. How do
> I then convert that to Unix-style, UTF-8?

First of all, don't do that.  Use POSIX paths.

Second, it's not passed as UTF-8 if the called application is a
non-Cygwin application.  In fact, Cygwin calls CreateProcessW, so all
strings are converted to UTF-16 (aka UNICODE) when starting a non-Cygwin
child process.

Third, as for Cygwin apps, don't use WIN_A, use WIN_W instead, because
that's encoding agnostic:

  main (int argc, char **argv)
    size_t len;
    wchar_t *w32_path;
    char *psx_path;

    setlocale (LC_ALL, "");

    len = mbstowcs (NULL, argv[1], 0) + 1;
    w32_path = (wchar_t *) malloc (len * sizeof (wchar_t));
    mbstowcs (w32_path, argv[1], len);
    psx_path = (char *) cygwin_create_path (CCP_WIN_W_TO_POSIX, w32_path);


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

Problem reports:
Unsubscribe info:

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