stat() lstat() not able to read long filename with cyrillic chars?
Corinna Vinschen
corinna-cygwin@cygwin.com
Thu Dec 24 19:24:00 GMT 2015
On Dec 23 20:44, Denis Corbin wrote:
> Hi,
>
> First, I have read the FAQ and this mailing archive :)
>
> Here is the problem I meet:
>
> In a directory are placed three files using windows 8's explorer:
> - a short Cyrillic filename "абваб.txt"
> - a long Cyrillic filename
> "абвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабвабваб.txt"
> - a long Latin filename
> "ababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababa.txt"
>
>
> >From a C program compiled under Cygwin, I can obtain the corresponding
> filename strings using readdir_r()...
>
> "\320\260\320\261\320\262\320\260\320\261.txt"
> "\320\260\320\261\320\262\320\260\320\261\320\262\320\260\320\261 [snipped]"
> "abababababaababababa [snipped]"
>
> ... but passing these strings in turn to lstat() or stat() returns 0 as
> expected for all except for the long Cyrillic filename.
NAME_MAX is 255. On Windows this is the number of UTF-16 chars
unfortunately. On POSIX systems (as on Cygwin) this is the number of
bytes. Long UTF-16 strings in cyrillic take twice as much UTF-8 chars
as it has UTF-16 chars, so NAME_MAX in utf-8 cyrillics translates into
a maximum of 127 UTF-16 chars.
If you need access to UTF-16 filenames with more characters, you can
switch to a one-byte charset temporarily, e.g.
$ LC_ALL=ru_RU your_app
to switch to iso-8859-5 or
$ LC_ALL=ru_RU.CP1251
to switch to Windows codepage 1251. See
https://cygwin.com/cygwin-ug-net/setup-locale.html
HTH,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20151224/4ed0d3f6/attachment.sig>
More information about the Cygwin
mailing list