In response to "
        If I understand you, you are saying that you are typing "é" in a utf8 html
       form, and getting "é" in your %ARGS variable.  Is that correct?

        "

Yes, arguments in %ARGS are UTF-8 well-formed. The problem is that it is send back to browser "as-is". I've found that you have to tell perl that strings in %ARGS are UTF-8 "flagged" before work on them and send it back. So the following code work now for me:

<%init>
        my $fif = HTML::FillInForm->new;
        my $data = "">

        my $form = $m->content;
        my @par_names  = $r->param();
         my $form_input = {};  

         foreach my $name ( @par_names ) {
                 my @val = $r->param( $name );

                foreach ( @val ) {
                            $_ = Encode::decode_utf8( $_ );
                 }
                        $name = Encode::decode_utf8( $name );

                if ( scalar @val == 1 ) {  
                        $form_input ->{$name} = $val[0];
                } else {                      
                        $form_input ->{$name} = [EMAIL PROTECTED];  # save value as an array ref
                }
        }
       
         if ($object ) {
             my $filled = $fif->fill( scalarref => \$form,
                                fdat => $form_input,
                                      fill_password => $fill_password
                                    );
             $m->print($filled);
         }
         else
         {
             $m->print($form);
         }
</%init>

Thanks for your help. Suggestions welcomed!




[EMAIL PROTECTED]

07/03/2006 23:46

       
        Pour :        Cyril SUDRE/USI/NORDO/DEPT/EDFGDF/[EMAIL PROTECTED]
        cc :        [email protected]
        Objet :        Re: [Mason] HTML::FillInForm with fdat et fobject - overwrite?



If I understand you, you are saying that you are typing "é" in a utf8 html
form, and getting "é" in your %ARGS variable.  Is that correct?

If so, "é" is in fact the utf8 encoding for the iso-8859-1 character "é",
so everything is working correctly.

On the other hand, if you are typing "é" in the form, and seeing "é" on
the result page, it means that you are actually outputting "é" to the
page, because something is converting the "é" to utf8 twice.  (Once when
the form is submitted, which is correct, and once sometime during the
process of assembling and outputting the page, which is bad.)  This could
be caused by a great variety of non-utf8 compliant modules, misplaced utf8
flags, and even bugs in perl itself.  But it is not mason-specific.

~ John Williams


On Tue, 7 Mar 2006, Cyril SUDRE wrote:

> No sure if it's mason specific. Please let me know.
>
> I'm trying to have my form handle UTF-8 encoded arguments correctly with
> HTML::FillInForm in a mason component.
> My pages are UTF-8 delivered with correct charset in html header. All work
> except when filtering my forms with HTML::FillInForms. The page render
> "UTF-8 encoded" arguments passed in URL.
>
> So a "é" in a text field is rendered as "é" when i submit.
>
> I've tried to decode string in %ARGS, but with no success.
> Any help appreciated.
>
> Cyril



Reply via email to