At 9:10 am +0900 26/12/05, Joel Rees wrote:
I note your are running both the script and the HTML in Unicode
UTF-8. There is wisdom in that, of course, and I may rethink my
choice of running these scripts in shift-JIS. (I like to avoid
conversions that require tables and context decisions as much as
possible.)
I simply hate legacy encodings. Having worked with Chinese on the
Mac since system 6, I would have switched to Windows NT if Apple had
not finally implemented Unicode in Mac OS 10. Having waited so long
for Unicode, I use nothing else now.
I also notice you are saving the file back to disk so you can
re-open it as shift-JIS. I want to avoid that, since perl is already
saving it once to a temporary directory anyway...
Yes, my script was simply a very badly implemented proof of concept.
Having looked at the question more deeply, I'm now half way through
doing a proper job making proper use of CGI.pm.
(Muttering to self -- can perl open strings as streams like Java?)
Yes.
I have now had a better look at CGI.pm and come up with a solution
that works, I think, as you want it. The curious thing is that some
browsers had no difficulty even before I used Encode->from_to.
To see the script go to <http://bd8.com/temp/> and view uploadj.pl.txt
To try it out go to:
<http://ccgi.bd8.com/cgi-bin/uploadj.pl>
At 2:27 am +0000 26/12/05, John Delacour wrote:
Do you know of a way to tell perl, or, rather, the CGI module to
open the file handle as shift-JIS?
open F, "<:encoding(shift_jis)", $f
Clearly the Christmas goose had affected my reason! As you were
about to tell me, CGI.pm has already opened the file handle; so if
you want to avoid writing the contents to another file and then
opening that as above, it is necessary to use Encode as shown
<http://bd8.com/temp/uploadj.pl.txt>
JD