- 论坛徽章:
- 0
|
本帖最后由 toniz 于 2011-01-19 17:56 编辑
提供你两种方法:一是把你的UTF-8全部改成GB2312
二是用Encode模块。UTF-8只是UNICODE的一种存储方式,这里你混淆了。帮你改下代码。- <html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
- <title>tf8 Example</title>
- </head>
- <body>
- 中文中文中文 <br>
- <form method="post" action="itest.cgi">
- <p>word: <input name="word" type="text">
- <input type="submit" name="Submit" value=" 查询 ">
- </form>
- </body>
- </html>
- -----------------------------------------------------
- #!/usr/bin/perl -w
- use CGI;
- use HTML::Entities;
- use utf8;
- use Encode;
- $query = new CGI;
- $secretword = $query->param('word');
- $remotehost = $query->remote_host();
- my $a = $secretword;
- $a = decode_entities($a);
- print $query->header( -charset=>'utf-8' );
- print encode("utf8",decode("gb2312",$a));
复制代码 |
|