X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 	tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin@cygwin.com
From: Lapo Luchini <lapo@lapo.it>
Subject:  Re: [1.7] Invalid UTF8 while creating a file -> cannot delete?
Date:  Wed, 16 Sep 2009 00:38:10 +0200
Lines: 41
Message-ID: <h8p50e$im8$1@ger.gmane.org>
References:  <h8bk5a$big$1@ger.gmane.org> <416096c60909101512l6e42ab72l4ba5fd792363eefd@mail.gmail.com>
Mime-Version:  1.0
Content-Type:  text/plain; charset=UTF-8
Content-Transfer-Encoding:  7bit
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0
In-Reply-To: <416096c60909101512l6e42ab72l4ba5fd792363eefd@mail.gmail.com>
OpenPGP: id=C8F252FB; 	url=http://www.lapo.it/pgpkey.txt
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Andy Koppe wrote:
> Hmm, we've lost the \xDF somewhere, and I'd guess it was when the
> filename got translated to UTF-16 in fopen(), which would explain what
> you're seeing

More data: it's not simply "the last character", is something more
complex than that.

% cat t.c
int main() {
    fopen("a-\xF6\xE4\xFC\xDF", "w"); //ISO-8859-1
    fopen("b-\xF6\xE4\xFC\xDFz", "w");
    fopen("c-\xF6\xE4\xFC\xDFzz", "w");
    fopen("d-\xF6\xE4\xFC\xDFzzz", "w");
    fopen("e-\xF6\xE4\xFC\xDF\xF6\xE4\xFC\xDF", "w");
    return 0;
}
% gcc -o t t.c
% ./t
% find .
.
./a-???
./b-???
./c-???
./d-???
./e-???????
./t.c
./t.exe

It seems that once one "high bit set" byte is encountered, everything
past the last of them (itself included) is lost.

Also, I can confirm this works too:
% rm a-$'\366'$'\344'$'\374'$'\337'
but also this, since last one doesn't count:
% rm a-$'\366'$'\344'$'\374'$'\336'
BTW: I didn't know about that kind of escaping, but zsh auto-completed
that for me (excluding the last character, of course)

-- 
Lapo Luchini - http://lapo.it/


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

