cygwincygpath

Cygpath and accents (àèìòù)


cygpath doesn't seem to correctly handle paths with accents, e.g.

C:\cygwin64\bin>cygpath --absolute -C UTF8 "C:\foo\àòè\foo2"

prints

/usr/bin/"C:/foo/àòè/foo2"

whereas I would expect:

/cygdrive/c/foo/àòè/foo2

The same path without accents yields the expected result:

C:\cygwin64\bin>cygpath --absolute -C UTF8 "C:\foo\aoe\foo2"
/cygdrive/c/foo/aoe/foo2

Am I doing something wrong?

------ EDIT 1

I'm using Cygpath 2.6.0 on Win 10.

C:\cygwin64\bin>cygpath --version
cygpath (cygwin) 2.6.0
Path Conversion Utility
Copyright (C) 1998 - 2016 Cygwin Authors
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

C:\cygwin64\bin>locale
LANG=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_ALL=

As far i see, after Adrian answer, I think that the problem is that I'm trying to use cygpath without running cygwin bash, because using that i don't have any problem.

$ cygpath --absolute -C UTF8 "C:\foo\àèò\foo2"
/cygdrive/c/foo/àèò/foo2

But I need to use cygpath directly without bash, do you think there is a way?


Solution

  • What version of Cygwin/cygpath do you run? I can't duplicate this:

    $ cygpath --absolute -C UTF8 "C:\foo\àòè\foo2"
    /cygdrive/c/foo/àòè/foo2
    
    $ cygpath --version
    cygpath (cygwin) 1.7.35
    Path Conversion Utility
    Copyright (C) 1998 - 2015 Red Hat, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    $ locale
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_ALL=en_US.UTF-8
    

    EDIT

    Works:

    Does not work:

    This seems to be related to quoting and there is a workaround. Specifying the path without quotes yields the correct result:

    c:\cygwin\bin>cygpath --absolute -C UTF8 'C:\foo\àèò\foo2'
    /cygdrive/c/cygwin/bin/'C:/foo/àèò/foo2'
    
    c:\cygwin\bin>cygpath --absolute -C UTF8 C:\foo\àèò\foo2
    /cygdrive/c/foo/àèò/foo2
    

    I'm not sure if/how the Cygwin devs support running Cygwin applications outside a Cygwin-shell but since this worked before I'd say it's a bug, you should post it to their mailing list.