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

acouch’s picture

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?

mcrickman’s picture

Version: 6.x-1.1-alpha2 » 6.x-1.1-beta1

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

$v = str_replace("&", " & ", $v);
$v = str_replace("amp;", "", $v);
$v = str_replace("#039;", "'", $v);
$val .= "$v\n";

Charlie

acouch’s picture

This makes sense. I will try and take a look.

letapjar’s picture

one potential problem here:

$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 "&amp" 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.

richardtmorgan’s picture

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.

bluegeek9’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.