[cgiapp] encoding pragma and CGI::Session

Ron Savage ron at savage.net.au
Tue Sep 28 02:19:18 EDT 2010


Hi Mark

On Mon, 2010-09-27 at 23:37 -0400, Mark Rajcok wrote:
> On Fri, Sep 3, 2010 at 8:31 PM, Ron Savage <ron at savage.net.au> wrote:
> 
> > Hi Todd
> > Thanx for the sample code.
> > More below.
> >
> > On Fri, 2010-09-03 at 09:08 -0700, Todd Ross wrote:
> > > CGI::Session: 4.20
> >
> > Firstly, you can get V 4.42 from CPAN and V 4.45 from the repository.
> > But, most importantly, I put a discussion of UTF8 in the docs:
> >
> >
> > http://search.cpan.org/~markstos/CGI-Session-4.42/lib/CGI/Session.pm#A_Warning_about_UTF8<http://search.cpan.org/%7Emarkstos/CGI-Session-4.42/lib/CGI/Session.pm#A_Warning_about_UTF8>
> >
> 
> Following the link I read this statement "Until this problem is understood
> and corrected, users are advised to avoid UTF8 in conjunction with
> CGI::Session".  Yikes!  Is it really that bad?  I'm using UTF-8 (everywhere
> in my app) with CAP::Session without any problems  (although with a MySQL
> backend for session storage, I did have to change the a_session field to a
> "blob").

He, he, he. That note is /meant/ to make each of us say Yikes!

As the author of that warning, I guess I can say I'm referring to my own
confusion here.

And I might add, no-one has offered replacement text ... Until your
article in wikibooks mentioned below.

> Todd, what was your intent with the   use encoding 'utf8';  line?  Do you
> only want to save and restore UTF-8 encoded session data?  or do you want to
> do that PLUS have Perl consider your script (i.e., file test.pl) to be
> encoded in UTF-8?  I ask because I find this to be a common misunderstanding
> about UTF-8.  The 'use encoding...' line is usually not what people should
> use.  If you only want the script to read/write UTF-8, and your script is in
> normal ASCII/ISO-8859-1 encoding, then try this instead of the 'use
> encoding..' line to get the script to read and write UTF-8 on stdin and
> stdout:
>   binmode STDIN, ":encoding(utf8)";
>   binmode STDOUT, ":encoding(utf8)";
> 
> With the above two lines, your script worked for me.

I find that with or without these 2 lines, the code works when:
use encoding 'utf8';
is not used, and fails when it is used.

I sure hope we're agreed on that.

> This might help: http://en.wikibooks.org/wiki/Perl_Programming/Unicode_UTF-8
> (something I wrote a while ago when trying to understand how UTF-8 works).

Thanks for the effort in writing such a marvellous article.

I'll change the POD for CGI::Session to (hopefully) clarify this issue,
and I'll include a reference to your article.

My attitude is that the POD for CGI::Session should not duplicate bits
and pieces of documentation, except in very special circumstances.
Rather it should refer to the original document.

So, I'll be reducing the amount of text in the POD.
-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622



More information about the cgiapp mailing list