Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: UTF-8 and URL encoding

by iguanodon (Priest)
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').

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337588]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2018-01-20 14:15 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (226 votes). Check out past polls.