Subject: bug#6705: w32 cmdproxy.c pass args to cygwin; erroneous charset conversion (problem description, solution/suggestion)

From: Eli Zaretskii <[email-masked]>
Date: Thu, 22 Jul 2010 22:50:21 +0300

> Date: Thu, 22 Jul 2010 15:31:44 +0300
> From: Laimonas Vėbra <[email-masked]>
> Cc: 
> 
> Below is a comment that i wrote for myself in the cmpdproxy.c (it 
> explains the problem). I have a half (i suppose -- portable enough) of 
> working solution/fix for it using MultiByteToWideChar API function, but 
> i won't send a (partly working) patch, unless someone from the 
> developers who agree with the problem and intend to fix it will ask for it.

Sorry, I cannot understand your comments.  You talk about corrupted
conversion, but never add any detailed explanations, just examples.
Could you please elaborate?

The only thing I understand is that conversion of Unicode characters
to a Windows codepage that doesn't support those characters will be
lossy.  That part is clear, but:

  . did you try setting up your Windows to use the UTF-8 codepage
    65001?

  . since Cygwin 1.7 switched to using UTF-8, it parted itself even
    further from native Windows applications, so you now have one more
    reason to use the Cygwin build of Emacs instead of the native one

> Besides, the patch itself is larger than 10 diff lines and it uses 
> (duplicates by copying) some helper functions/declarations 
> (open_input_file(), close_file_data(), rva_to_section(), 
> w32_executable_type, RVA_TO_PTR) from unexw32.c, so it may need some 
> code refactoring.

This means we will be unable to accept the patches, even if we agree
to them, without you signing legal papers assigning copyright to the
FSF.

> how do one can/should (clearly) pass utf-8 arguments to an external 
> (cygwin) app on windows? I suppose, now it's not possible.

The Windows build of Emacs doesn't yet use the UTF-16 APIs.  Doing
that is a large job; volunteers are welcome, of course.  However,
passing UTF-8 arguments to subprocesses is hardly the first or the
most important thing that should be done in that regard, IMO.  File
access is much more important, this being an editor.