develooper Front page | perl.perl5.porters | Postings from March 2013

RE: [perl #117265] [PATCH] e213661 no warnings 'safesyscalls', fatal nul checks

Thread Previous | Thread Next
From:
Steve Hay
Date:
March 25, 2013 14:54
Subject:
RE: [perl #117265] [PATCH] e213661 no warnings 'safesyscalls', fatal nul checks
Message ID:
67B2BB40A61BE846B65EF4793B863D6C6C63C2@ukmail02.planit.group
demerphq wrote on 2013-03-25:
> On 25 March 2013 15:41, Steve Hay <Steve.Hay@verosoftware.com> wrote:
>> Leon Timmermans wrote on 2013-03-25:
>>> On Mon, Mar 25, 2013 at 3:14 PM, demerphq <demerphq@gmail.com>
> wrote:
>>>> Reini, on Win32 filenames are stored internally as UTF-16. What
>>>> affect does your patch proposal have on opening files with
>>>> widecharacters in them? (Widecharacters as you know could easily
> contain nuls).
>>> 
>>> Perl uses legacy interfaces on Windows (that is, it accesses the
>>> filesystem using 8-bit interfaces, the encoding is system-defined
but
>>> tends to be latin-1, which saves our ass most of the time).
>>> 
>>> I'd consider this our number one Windows bug (because it screws up
>>> badly when trying to open files with Unicode in their names), but
>>> fixing this will be non-trivial, and few people have the
>>> appropriate Windows knowledge anyway.
>>> 
>> 
>> It is possible to open Unicode filenames on Windows using
>> Win32API::File (see below). I assume this will at least still work?
>> 
>> use Encode qw(encode);
>> use Fcntl;
>> use Win32API::File qw(CreateFileW OsFHandleOpenFd :Misc :GENERIC_);
>> 
>> my $filename = "\x{65e5}.txt\0";
>> my $utf16le_filename = encode('UTF-16LE', $filename, 1);
>> 
>> my $h = CreateFileW($utf16le_filename, GENERIC_WRITE, 0, [],
> CREATE_NEW, 0, []);
>>         die "[write] CreateFileW: $^E\n" unless $h > 0; my $fd =
>>         OsFHandleOpenFd($h, O_WRONLY); die "[write] OsFHandleOpenFd:
>>         $^E\n" unless $fd > 0; open my $fh, ">&=$fd"; die "[write]
>>         open: $!\n" unless $fh; print $fh "Hello,
>> world.\n"; close $fh;
> 
> Is there an open ticket about this bug? (IOW, that Perl cant open
> widechar filenames without jumping through the proverbial hoop?)
> 
>

Not sure whether there is an RT ticket for this specific issue without
having a look, but it's all tied up with the "Unicode in Filename" and
"Virtualize operating system access" items in Porting/todo.pod...


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About