Well, it looks like Allen is in fact telling the browser which encoding to
use, both in the header and the document.  I think he is trying to figure
out why he has to set it to UTF-8 when he believes the text is in gb2312.
I believe that perl is printing the text as UTF-8 because it isn't being told
otherwise.

Regards,

-- Brad

On Fri, Mar 14, 2008 at 8:11 AM, Dawid Joubert <djspy187@gmail.com> wrote:
Hi Allen,
 
You can tell the browser what encoding to use for an HTML document. The first way is to use HTTP Response headers by providing the right Content-Type header example:
Content-Typetext/html; charset=UTF-8
 
The second way is to include it in the HTML document itself as a meta tag
 
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Accomodation</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
</head>
 
You should be doing the above anyway as it does not rely on any browser defaults and UTF-8 is the way forward as it does not limit the character set.
 
 
Regards
David
 
----- Original Message -----
From: Allen Zhang
Sent: Friday, March 14, 2008 9:06 AM
Subject: [htmltmpl] Help! Chinese character displaying problem usingHTML::TEMPLATE

Hi all,

    My cgi script using Html::Template having some error display Chinese Character.
    I have set character set to gb2312, and the encoding character set was set to gb2312 too.
    But in  that case, the "" wasn't displayed as expected.
    However, I found that if I change the encoding character set of my browser to utf8, it displays perfectly.
    Why ?
    Most browsers in China were set to gb2312 encoding, I don't want users to manually change their
    default setting to view my page.
    What can I do?
    Thanks!!  


cgi code:
##################################################
#!/usr/bin/perl -w

use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use HTML::Template;

my $template = HTML::Template->new(filename => 'title.tpl.php');
my $title = '';
$template->param('title' => $title);
print header(-charset=>"gb2312");

print $template->output;

template code:
##################################################
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="description" content="">
<meta name="keywords" content="">
<title><TMPL_VAR NAME=title></title>
</head>
<body>
<TMPL_VAR NAME=title>
<br>
Hello!
<br>
Hard code
</BODY>
</HTML>



Allen Zhang


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/


_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users