Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi
i'm using CGI.pm to make a form script
and i would like to know how can i switch the page direction
to disply from right to left
and my other question is how to change the page encoding?
i'm just improting the standard module
waiting your answer ,
Thanks

Replies are listed 'Best First'.
Re: some questions on cgi.pm
by ikegami (Patriarch) on Jul 27, 2005 at 15:30 UTC

    If you're using CGI's document generating functions,

    Use start_html's -dir => 'rtl' parameter to specify right-to-left direction.

    Use header's -charset => '...' parameter to specify the character set. (In HTTP terms, encoding means something else, so I hope this is what you meant.)

Re: some questions on cgi.pm
by phaylon (Curate) on Jul 27, 2005 at 14:50 UTC
    Haven't looked into CGI.pm lately, but the text-direction seems more like a (X)HTML issue to me.
    Also: What problems did you have with the docs at CGI?

    Ordinary morality is for ordinary people. -- Aleister Crowley
Re: some questions on cgi.pm
by friedo (Prior) on Jul 27, 2005 at 15:22 UTC
    You can set the character encoding with CGI's start_html method. For example, to use the Hebrew ISO-8859 codepage,

    my $q = CGI->new; print $q->header; print $q->start_html( -encoding => 'iso-8859-8' );

    You could also use UTF-8 which is probably more widely supported these days. The direction of the text display is up to the browser to handle properly and can't be controlled from your script.

      That just sets the encoding for the XML prolog - it doesn't influence the HTTP Content-type, and under HTTP rules the Content-type trumps anything else for determining the character encoding. (See ikegami's comment for setting the HTTP header)