[Catalyst] UTF-8 and mails

Bill Moseley moseley at hank.org
Mon Jan 25 16:20:03 GMT 2010


On Mon, Jan 25, 2010 at 6:54 AM, Bernhard Graf <catalyst4 at augensalat.de>wro=
te:

>
> Does Mail::Sender::Easy automatically encode "_text" into the encoding
> given in charset? If not, then /you/ have to do it:
> Encode::encode("utf-8", $string);
>

That's what I do.   Specifically, I have this for generating inline text
emails:


        for my $template ( @templates ) {
            my $body_content =3D $self->render_email_template( $template,
$c->{stash} );

            push @parts, Email::MIME->create(
                attributes =3D> {
                    content_type =3D> ( $template =3D~ /_html$/ ? 'text/htm=
l' :
'text/plain' ),
                    charset      =3D> 'utf-8',
                    disposition  =3D> 'inline',
                    encoding     =3D> 'base64',
                },
                body =3D> encode_utf8( $body_content ),
            );
        }

    }



> Concerning "use utf8": As soon as you have any non-ASCII literals in
> your code ("Herr M=FCller"), then you want to use that, BUT only if your
> perl code file is also utf-8 encoded. Read the perl man pages about
> unicode, if you are not sure. Read them twice, and then once more. ;-)
> It's not a shame, if you don't get the whole picture at first.
>

And IMO string literals are better left in templates, in the databaes, and
.po files.

I use English, so I don't worry about utf-8 variable names.  I always
assumed at some point utf8 would become the default for Perl source, though.



-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100125/119c2=
be5/attachment.htm


More information about the Catalyst mailing list