I used to have problems with this, which appeared to have been solved in a later version of HTML::Tree. Try using encode_utf8($string) (from the Encode module) instead of $string
Moshe
* Terrence Brannon <[EMAIL PROTECTED]> [17/11/05 21:06]:
> I would like to know how to place Unicode character sequences in an HTML
> file whose charset is utf-8. The plain perl program below works fine for
> this purpose, but I don't know what to do to get the HTML::TreeBuilder
> version to work.
>
> Also: I am not sure if this will remain the official support channel for
> HTML::Tree now that it has changed hands, so I am cc'ing the new maintainer
> as well.
>
> # Working Program
>
> use strict;
> #use utf8;
>
> my $string = "m\x{c3}\x{b8}\x{c3}\x{b8}se";
>
> open O, '>moose.html' or die $!;
>
> print O <<"EOHTML";
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> </head>
> <body>
> $string
> </body>
> </html>
> EOHTML
>
> # Fails to preserve unicode characters
>
> use strict;
> use HTML::TreeBuilder;
>
>
> my $string = "m\x{c3}\x{b8}\x{c3}\x{b8}se";
>
> open O, '>tbmoose.html' or die $!;
>
> my $tree = HTML::TreeBuilder->new_from_content(<<"EOHTML");
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> </head>
> <body>
>
> </body>
> </html>
> EOHTML
>
> my $body = $tree->look_down('_tag' => 'body');
> $body->push_content($string);
>
> print O $tree->as_HTML;
pgp8X6sNWhk4u.pgp
Description: PGP signature
