in reply to UTF-8 and URL encoding

I have a cgi generating an html page with the following meta tag: <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">. This causes my browser (Mozilla 1.6) to set it's character coding to utf8
Does it? Have you checked in Mozilla to see that it really is using utf8 encoding? If your HTTP header is not sending utf8, then I don't believe the meta tag is doing what you expect. I'd set the encoding in the HTTP header by calling header(-charset=>'utf-8').

Replies are listed 'Best First'.
Re: Re: UTF-8 and URL encoding
by eserte (Deacon) on Mar 18, 2004 at 10:30 UTC
    Yes, it does. The rule is: GET and POST parameters are encoded in the charset of the page. Try this html page with your browser, alternatively with utf-8 and iso-8859-1:
    <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <!-- meta http-equiv="content-type" content="text/html; charset=utf-8" --> </head> <body> <script> document.write( + "<br>"); </script> <form> <input type="hidden" name="test" value="&auml;"> <input type="submit"> </form> </body>
      Right, but that's static HTML. Try this and look at what your browser thinks the encoding is:

      #!/usr/local/bin/perl use strict; use warnings; use CGI qw(:standard); print header(); print <<HTML; <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <script> document.write( + "<br>"); </script> <form> <input type="hidden" name="test" value="&auml;"> <input type="submit"> </form> HTML print end_html();

      Unless you tell it not to, will set the encoding to iso-8859-1 in the HTTP header. In this case the meta tag has no effect, at least in recent versions of IE and Mozilla.