surrounding double quotes not removed from native command line arguments when they contain unicode and locale is default

basinilya@gmail.com basinilya@gmail.com
Thu Nov 12 16:10:40 GMT 2020


Hi.
When I launch a Cygwin program from a native Windows program and an argument in the command line string is quoted and contains national characters then the Cygwin program behaves as if double quotes were part of the program argument.
This happens if I don't explicitly set LC_ALL or if I set LC_ALL=C or set LC_ALL=C.UTF-8

This is a problem because arguments with spaces must be quoted.

If I set the locale to some language and country the quotes are removed as expected no matter what code page I use, UTF-8 or a single-byte code page. The locale doesn't have to match the alphabet used.

If the argument is not quoted or if it doesn't contain national characters then it works even with the C locale.

    C:\>set LC_ALL=
    
    C:\>C:/cygwin/bin/ls -l C:/test-z-я/some.txt
    -rw-r--r-- 1 il None 0 Nov 12 09:52 'C:/test-z-'$'/321/217''/some.txt'
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    /usr/bin/ls: cannot access '"C:/test-z-'$'\321\217''/some.txt"': No such file or directory
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-Z/some.txt"
    -rw-r--r-- 1 il None 0 Nov 12 09:52 C:/test-z-Z/some.txt
    
    C:\>C:\cygwin\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=
    
    C:\>set LC_ALL=C.UTF-8
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    /usr/bin/ls: cannot access '"C:/test-z-я/some.txt"': No such file or directory
    
    C:\>set LC_ALL=en_US.CP1252
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    -rw-r--r-- 1 il None 0 Nov 12 09:52 'C:/test-z-'$'/030''N'$'/217''/some.txt'
    
    C:\>set LC_ALL=en_US.UTF-8
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    -rw-r--r-- 1 il None 0 Nov 12 09:52 'C:/test-z-я/some.txt'
    


More information about the Cygwin mailing list