On Apr 6, 2005, at 3:03 PM, John Delacour wrote:

At 12:08 pm -0400 6/4/05, Andrew Mace wrote:

Any insights would be appreciated.

What happens if you comment out

#use utf8;
...
#binmode(*STDOUT, ":utf8");
...
        #binmode($fh, ':bytes'); # :utf8 ?
...
        #binmode($fh, ':bytes');


It seems to work then as you want:

         <http://cgi.bd8.com/cgi-bin/test050406.cgi>

JD


Well, I get the same result as before - file itself saves okay, HTML page reports back okay, but when viewing in BBEdit (UTF-8, no BOM), the name of the file in test.txt doesn't render correctly - other form fields with extended charset data do, though. When I paste into Mail, though, it looks fine, so I have no idea what's going on. When I write the name to file with :utf8 and then try to read back in as :utf8 to send back to the browser, it gets totally hosed, that is:

$filename = decode_utf8($filename);
....
$fh->open('> test.txt');
binmode($fh, ':utf8');
print $fh $filename;
$fh->close;
....
$fh->open('< test.txt');
binmode($fh, ':utf8');
$filename = <$fh>;
$fh->close;
....# HTML stuff
print $filename, '<br />';

If the string's utf8 flag is enabled, perl won't try to reencode when I write to a :utf8 opened file, right? I just don't understand why this field is different from the other, non-file, form fields in multipart/form-data.

Shouldn't I be using :utf8? If I don't always use that layer, things can easily get corrupted, right? Double encoding, and such as I reopen and append, etc.? And since I have UTF-8 characters in my script, I should "use utf8;" to let perl know and binmode(*STDOUT,':utf8') so that I'm not lying when I say Content-Type: text/html; charset=utf-8?

Thanks
Andrew





Reply via email to