Posted by mcrickman on October 14, 2009 at 4:29pm
Jump to:
| Project: | Mailing Label |
| Version: | 6.x-1.1-beta1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
When a labels output has a '&' the pdf will output the ISO: & this is true for ' and " too.
Can this be corrected easily?
Charlie
Comments
#1
This uses the ufpdf converter to make the pdfs using the UTF-8 character set. From your question I'm not really sure what your issue is. Can you rephrase?
#2
If your label contains an '&' sign the printed output is '& a m p ;' minus spaces.
I wrote this as a work around.
mailing_label.module.php line 85
<?php
$v = str_replace("&", " & ", $v);
$v = str_replace("amp;", "", $v);
$v = str_replace("#039;", "'", $v);
$val .= "$v\n";
?>
Charlie
#3
This makes sense. I will try and take a look.
#4
one potential problem here:
<?php$v = str_replace("amp;", "", $v);
?>
this line would replace ALL matches of "amp". but if my contact lives on "Lamplight Lane" this would be
changed to "Llight Lane" by the above code.
why is this line even necessary?
Once the line above replaces "&" correctly there should be no more "amp" representing the ampersand correct?
Have you tried using html_entitiy_decode() ?
This is probably the best way to properly get your ampersands and quotes back and should safely un-do what the check_plain() is doing in the plugin display attachment.
#5
I tried this with html_entity_decode() (you need to add the ENT_QUOTES constant to get it to process quotes too :-))
The strangest behaviour - which I won't try to explain - is that you need to run $v through html_entity_decode() twice - once when you add it to $val and once prior to that. Modifying existing line 85 (
$val .= "$v\n";) to these two lines:$v = html_entity_decode($v, ENT_QUOTES);$val .= html_entity_decode($v, ENT_QUOTES) . "\n";
sorted it fine.
Presumably this is why Charlie in #2 ended up needing to run his string replace on & twice. Why? I've no idea - but the fix I've implemented does produce the right output.