all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#28180: [w32] Unicode characters in subprocess (git) arguments changed to space
@ 2017-08-22  2:35 npostavs
  2017-08-22 14:54 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: npostavs @ 2017-08-22  2:35 UTC (permalink / raw)
  To: 28180

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

In w32.c there is a comment saying

   . Running subprocesses in non-ASCII directories and with non-ASCII
     file arguments is limited to the current codepage [...]
     This should be fixed, but will also require changes in cmdproxy.
     The current limitation is not terribly bad anyway, since very
     few, if any, Windows console programs that are likely to be
     invoked by Emacs support UTF-16 encoded command lines.

I believe we're running into this limitation with git: staging a file
named 好.txt fails from magit[1] (I tried also with vc, same problem).
A quick way to see the problem is evaluating the call-process form
below, the output shows that the Chinese character has been transformed
into a space.  This happens even if I execute 'chcp 65001' before
starting Emacs (a possible workaround I saw suggested in a few places).
The short file name trick doesn't help either.

(call-process "git" nil '(t t) nil
              "-c" "alias.x=!x() { printf '%s' \"$1\" | od -tx1; }; x" "x" "(好)")
0000000 28 20 29
0000003

As far as I can tell, git does support UTF-16 encoded command lines, as
demonstrated by the attached git-args.c, which produces the utf8
encoding of the character (this is also what the call-process form
produces when I run it on GNU/Linux):

C:\Users\npostavs\src\win32-args>.\git-args.exe
0000000 28 e5 a5 bd 29
0000005


[-- Attachment #2: test program, C source --]
[-- Type: text/plain, Size: 883 bytes --]

#include <windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    STARTUPINFOW wsi;
    PROCESS_INFORMATION pi;

    WCHAR wcmdline[] = L"git -c \"alias.x=!x() { printf '%s' \\\"$1\\\" | od -tx1; }; x\" x (\x597d)";

    ZeroMemory( &wsi, sizeof(wsi) );
    wsi.cb = sizeof(wsi);
    ZeroMemory( &pi, sizeof(pi) );

    if (!CreateProcessW(NULL, wcmdline,
            NULL, NULL, // proc, thread attrs
            FALSE, // handle inheritance
            0, // creation flags
            NULL, // env
            NULL, // cur dir
            &wsi,
            &pi)) {
        printf( "CreateProcess failed (%d).\n", GetLastError() );
        return 1;
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    return 0;
}

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]


Am I correct that this problem is related the w32.c comment?  It's not
clear to me what changes are needed in cmdproxy (and other places?) to
address it.

[1]: https://github.com/magit/magit/issues/3111

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-29 22:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22  2:35 bug#28180: [w32] Unicode characters in subprocess (git) arguments changed to space npostavs
2017-08-22 14:54 ` Eli Zaretskii
2017-08-28 14:42   ` Noam Postavsky
2017-08-28 17:15     ` Eli Zaretskii
2017-08-29 22:06     ` Noam Postavsky

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.