How to create a file name with UTF-8 characters in Cygwin

Viewed 206

Using a shell script run under Cygwin, I want to create a file name which contains Danish characters (Ø, Æ, and Å). I have a bash script which basically does this: echo "some data" > "file name with Danish letters.txt". After running such script, all Danish letters look like a dot in the file name. I have tested this using Cygwin 32 under Windows 7 and Cygwin 64 under Windows 10. The locale command produces the following:

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=

Running:

echo "rødgrød" | od -ctx1

produces this:

0000000   r 303 270   d   g   r 303 270   d  \n
         72  c3  b8  64  67  72  c3  b8  64  0a
0000012

Here is an example of how the bash script looks like:

echo "some data" > "Peter Sørensen.txt"

The letter ø looks like a dot when I look at the created file name in Windows. Here is a screenshot of the file name:

enter image description here

In cygwin, running the ls command results in this message:

ls: cannot compare file names ‘Peter S\370rensen.txt’ and ‘test.sh’: Invalid or incomplete multibyte or wide character

And here is a screenshot of how this file name looks like in cygwin terminal after running the ls command:

enter image description here

0 Answers
Related