in reply to Re^2: CGI.pm encoding - wrong encoding for ě
in thread CGI.pm encoding - wrong encoding for ě
it works for this particular file but not for my complex script
I do not understand. What is a complex script? What does not work? Explain this, use more words.
How can I force CGI to use utf8 as default?
Exactly as I have shown. There are several parts to it:
1. use utf8; lets you write literal UTF-8 characters in Perl source code. If you always use Perl escapes instead, such as \x{11b} and HTML escapes, such as ě, so that you have ASCII-only source-code, this pragma is not neccesary.
2. The header method sets the HTTP header with the appropriate encoding. You seem to be under the misconception that <meta name="charset" content="utf-8"/> is enough. In fact the HTTP header is always relevant, and the in-file meta header only is taken into consideration when the HTTP header is absent, e.g. when the HTML is loaded from the file system.
3. CGI writes to STDOUT. The binmode method inherited from IO::Handle sets the encoding to UTF-8 for any STDOUT output, e.g. print method.
And how is it possible that all other national chars (ščřžýáíéůú) are good
I do not understand this question. All characters have the same properties, or nearly so, so of course they behave the same as with ě from the original example. Perhaps you should start to show some source code to demonstrate what you mean.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: CGI.pm encoding - wrong encoding for ě
by tobyink (Canon) on Jan 25, 2012 at 14:16 UTC | |
|
Re^4: CGI.pm encoding - wrong encoding for ě
by koszta5 (Initiate) on Jan 25, 2012 at 14:24 UTC | |
by Corion (Patriarch) on Jan 25, 2012 at 14:28 UTC | |
|
Re^4: CGI.pm encoding - wrong encoding for ě
by koszta5 (Initiate) on Jan 25, 2012 at 13:46 UTC | |
by Anonymous Monk on Jan 25, 2012 at 14:05 UTC | |
|
Re^4: CGI.pm encoding - wrong encoding for ě
by koszta5 (Initiate) on Jan 25, 2012 at 14:45 UTC | |
by Anonymous Monk on Jan 26, 2012 at 01:40 UTC |