José Parrella | 10 Feb 23:28

[FormBuilder] Using UTF-8 templates in CGI::FB

Greetings,

I've been developing a UTF-8 based Web application in spanish (es_ES)
with CGI::FormBuilder, which already provides templates for this
language. However, I get weird characters in all JS messages, as well as
errors from the W3C Validator. Please note that I'm not an expert in
this topic, but I think I've narrowed the problem to:

a) The es_ES.pm messages file is encoded in ISO-8859-1 (I opened it with
a UTF-8 aware text editor and rewrote it, then checked it with `file
es_ES.pm` which says that now it is a UTF-8 file)

b) The functions in FormBuilder.pm that write the actual JavaScript code
are using "return <string>", and this last step is not UTF-8 aware (I
don't know why, though). If I add "use Encode;" and then return
encode_utf8(<string>); I get the proper code in the HTML output.

Also, most scripts I checked in were not using "use utf8;". I don't know
if this is mandatory of if it actually helps with something, but just in
case. Can somebody explain to me a proper way to do UTF-8 based forms
with sane characters in the JS alerts and so on?

Jose

--

-- 
José M. Parrella -> Debian Sid, k2.6.18
Escuela de Ingenieria Electrica
Universidad Central de Venezuela -> ucvlug.info
_______________________________________________
FBusers mailing list
(Continue reading)

Rod McChesney | 11 Feb 01:47

Re: [FormBuilder] Using UTF-8 templates in CGI::FB

Can't speak to the FB message handling, because we bypass it in
favor of templatized Locale::Maketext calls, but one thing to check is
whether you are setting the HTML page's content type to indicate
that the charset is utf-8. You can set it in the HTTP Content-Type
header or as a meta-equiv tag in the HTML itself, but you need to
get that done.

In general you shouldn't need "use utf8" as long as you've got
a reasonably recent Perl (5.8, not 5.6). Beyond that I'm not sure
what else to check -- we have got this kind of thing working reasonably
well but not with Template Toolkit, not FB's own layout.

HTH,

Rod

José Parrella wrote:
> Greetings,
> 
> I've been developing a UTF-8 based Web application in spanish (es_ES)
> with CGI::FormBuilder, which already provides templates for this
> language. However, I get weird characters in all JS messages, as well as
> errors from the W3C Validator. Please note that I'm not an expert in
> this topic, but I think I've narrowed the problem to:
> 
> a) The es_ES.pm messages file is encoded in ISO-8859-1 (I opened it with
> a UTF-8 aware text editor and rewrote it, then checked it with `file
> es_ES.pm` which says that now it is a UTF-8 file)
> 
> b) The functions in FormBuilder.pm that write the actual JavaScript code
(Continue reading)


Gmane