erm I think I forgot to point out what I changed --
Now, as far as my little problem goes, I was able to get some success
with the following:
-----------------snippet------------------
use encoding( 'Shift_JIS' );
...
my $query = new CGI;
...
my $fileToSend = $query->param( 'file-to-send' );
my $FileSent = $query->param( 'FileSent' );
...
elsif ( $FileSent )
{
my $fh;
if ( !defined( $fileToSend ) || length( $fileToSend ) < 1 || !(
$fh = $query->upload( 'file-to-send' ) ) )
{ print $query->header(-status=>$error),
$query->start_html( 'Bad request' ),
$query->h2( 'Failed to find or open file, maybe bad
file name selected.' ),
$query->strong( "Upload request for $fileToSend not
processed." );
exit 0;
}
my $type = $query->uploadInfo( $fileToSend )->{ 'Content-Type' };
if ( $type ne 'text/plain' )
{ print $query->header(-status=>$error),
$query->start_html( 'Bad file type' ),
$query->h2( 'File type must be plain text.' ),
$query->strong( 'Request not processed.' );
exit 0;
}
# One line at a time is STILL not safe if length not already
checked.
# Doing this one line at a time to handle the shift JIS problem,
somehow.
my @fileLines = ();
my $line = '';
# binmode( $fh, ":raw :encoding(Shift_JIS)" );
This is what seems to get it to upload from the iBook to itself:
binmode( $fh, ":raw :utf8" ); # As best as I understand, this
should be wrong.
The debug stuff below didn't really tell me much beyond that it was
already not shift-jis by the time the script was reading it from the
CGI upload function.
# binmode( $fh, ":raw" );
while ( $line = <$fh> )
{
my @hexdump = unpack( 'C256', $line ); # debug
my $hexdumpstring = ''; # debug
foreach my $byte ( @hexdump ) # debug
{ $hexdumpstring .= sprintf( '%02x ', $byte ); # debug YUCK!
} # debug
push( @fileLines, $line );
push( @fileLines, $hexdumpstring . "\n" ); # debug
}
@words = @fileLines;
...
---------------end-snippet----------------
This is in spite of the headers, the XML declaration, and the HTML
header meta declaration all declaring the document to be shift-JIS,
and the source itself declaring "use encoding( 'Shift_JIS' );". I
should probably expect that I muffed it when I compiled perl, but I'll
need to push the whole thing onto my Linux/BSD box, bring up apache
over there, and compare notes to have a decent idea what's going on.
In the meantime, Firefox on Linux is no longer uploading the file at
all.
Joel