Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: UTF-8 and URL encoding

by iguanodon (Curate)
on Mar 18, 2004 at 02:37 UTC ( #337588=note: print w/ replies, xml ) Need Help??

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').

Comment on Re: UTF-8 and URL encoding
Download Code
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337588]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2014-09-18 01:52 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (104 votes), past polls