1
votes

I have a perl cgi program which output to a simple html form for user data input. The form is in chinese big5 charset

When opened the cgi script, I have to manual switch web browser charset encoding to big5.

I searched on google and I found a method to set charset. Then

original code

$q = new CGI;
print $q->header;

to new code

$q = new CGI;
print $q->header(-charset=>'big5');

However, it just output a blank html.

3

3 Answers

3
votes

This works for me:

use CGI;
my $q = CGI->new();
print $q->header(-charset => 'big5');
print '簡體字';

When i try it, it will be showed correctly. (Make sure, that your script is also saved in big5).

1
votes

If those are the only two lines, then it's probably working.

Run the cgi from command line and you should see:

Content-Type: text/html; charset=big5
0
votes

You're printing headers, but no content, so the page will be blank. Use Firebug or similar to verify the response from the server.