This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
API request: export internal_setlocale
- From: Andy Koppe <andy dot koppe at gmail dot com>
- To: cygwin-developers at cygwin dot com
- Date: Sun, 7 Feb 2010 19:57:10 +0000
- Subject: API request: export internal_setlocale
I'm looking at changing mintty's drag&drop feature to insert POSIX
filenames instead of Windows filenames. In principle, converting the
filenames is just a matter of invoking cygwin_conv_path with
CCP_WIN_W_TO_POSIX. Trouble is, mintty's own filename charset (as
determined by its environment at startup) isn't necessarily the same
as that of its child process. That's because the user can choose
locale and charset in the mintty options and the child process' LANG
variable is set accordingly.
So something like this would currently be needed:
- cygwin_conv_path with CCP_WIN_W_TO_POSIX
- call setlocale(LC_CTYPE, "") to switch to mintty's original locale
- call mbstowcs to convert the POSIX path (encoded in mintty's
filename charset) to Unicode
- call setlocale(LC_CTYPE, <locale>) to switch to the child process's locale
- call wcstombs to convert the POSIX path from Unicode to the child
process's filename charset
There's a number of problems with this:
- It's ugly and inefficient, even more so now that setlocale might
need to read /usr/share/locale/locale.alias.
- It's not threadsafe.
- It doesn't deal with ^X escapes.
And now that I'm thinking about it, I realise that mintty's Ctrl+click
feature for opening a file has much the same issue and ought to do the
same process in reverse. But all this could be avoided if mintty was
able to change its filename charset to that of its child process.
Therefore it would be really nice if Cygwin's internal_setlocale(void)
function, which changes the filename/console charset according to the
currently selected LC_CTYPE locale, could be exported from the DLL.
Perhaps as a case for cygwin_internal()?
Andy