Skip to main content.
home | support | download

Back to List Archive

Re: XML2 parser error?

From: Peter Karman <karman(at)not-real.cray.com>
Date: Fri Jul 30 2004 - 15:50:43 GMT
jeesh. just ignore me (in general, if you want to). this is what I meant:

my $unsafe;
$unsafe .= chr for (9, 10, 13);

$contents = "<xml>\n" .
HTML::Entities::encode_entities($contents,$unsafe) .
"\n</xml>";


Peter Karman wrote on 7/30/04 10:47 AM:

> oh wait, that isn't right. that'll encode everything like a-z0-9, etc.
> 
> better to explicitly name the chars you want encoded, though. someone 
> with a clearer head than me this a.m. could list the chars that are 
> truly unsafe for libxml2. if, as Keith says, 9, 10 and 13 are legit, 
> than perhaps this would work better:
> 
> my $unsafe;
> $unsafe .= chr for (0 .. 8, 11, 12, 14 .. 32);
> $contents = "<xml>\n" .
> HTML::Entities::encode_entities($contents,$unsafe) .
> "\n</xml>";
> 
> Peter Karman wrote on 7/30/04 10:16 AM:
> 
> 
>> my @unsafe = 0 .. 32;    # or whatever ascii you DON'T want encoded
>> my $unsafe;
>> $unsafe .= chr for @unsafe;
>>
>> $contents = "<xml>\n" . HTML::Entities::encode_entities($contents, 
>> "[^$unsafe]") .
>> "\n</xml>";
>>
> 
> 

-- 
Peter Karman - Software Publications Engineer - Cray Inc
phone: 651-605-9009 - mailto:karman@cray.com
Received on Fri Jul 30 08:50:55 2004