Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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(location.search + "<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(location.search + "<br>"); </script> <form> <input type="hidden" name="test" value="&auml;"> <input type="submit"> </form> HTML print end_html();

      Unless you tell it not to, CGI.pm 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-09-21 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (176 votes), past polls