[Foomatic] [patch] PPD.pm: handle non-ASCII in PPDs
Till Kamppeter
till.kamppeter at gmx.net
Fri Nov 26 16:18:47 PST 2004
Thanks for the patch.
Is it correct that this patch simply replaces the 8-bit characters by
"?"? Should one not escape them somehow that the characters are conserved?
Till
Tim Waugh wrote:
> Hi,
>
> There is a problem in PPD.pm that needs some explaining.
>
> Some PPD files contain non-ASCII characters, i.e. the top bit is set,
> and we don't necessarily know the character encoding being used. This
> may occur in option names, for example, and ultimately may re-appear
> in generated XML.
>
> Unfortunately, this won't parse at all unless the encoding is given.
>
> Here is a patch I made which works around this problem. What do you
> think? (My perl is rusty so forgive me if there is a more obvious
> approach.)
>
> Tim.
> */
>
> --- foomatic-db-engine-3.0.2/lib/Foomatic/PPD.pm.bad-utf8 2002-10-11 02:16:34.000000000 +0100
> +++ foomatic-db-engine-3.0.2/lib/Foomatic/PPD.pm 2004-11-23 19:32:26.000000000 +0000
> @@ -300,11 +300,17 @@
> sub xml_esc {
> my ($in) = (@_);
>
> - $in =~ s!&!&!g;
> - $in =~ s!<!<!g;
> - $in =~ s!>!>!g;
> + @chars = split(//,$in);
> + $ascii = "";
> + foreach (@chars) {
> + if (ord ($_) > 127) { $_="?"; }
> + $ascii .= $_;
> + }
> + $ascii =~ s!&!&!g;
> + $ascii =~ s!<!<!g;
> + $ascii =~ s!>!>!g;
>
> - return $in;
> + return $ascii;
> }
>
> sub pdq_filter {
>
More information about the Printing-foomatic
mailing list