|
|
Choosing A Webhost: |
HTML::Tree, Unicode, and utf-8: msg#00013lang.perl.modules.lwp
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;
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: POST with attachment issues, Alexis Marrero |
|---|---|
| Next by Date: | Re: HTML::Tree, Unicode, and utf-8, Terrence Brannon |
| Previous by Thread: | follow location, Fabio Marzocca |
| Next by Thread: | Re: HTML::Tree, Unicode, and utf-8, Terrence Brannon |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |