• dtweney

    (@dtweney)


    Hi all.

    Public subscribers receive plain-text excerpts only, correct?

    The issue I have is that some nonbreaking spaces (  in HTML) are appearing in these plain-text emails sent to public subscribers. On some clients they look like this:

    B!

    B!

    Is there any way to strip out the nonbreaking spaces from the plain-text excerpts before delivery?

    Dylan.

    • This topic was modified 7 years ago by dtweney.
Viewing 6 replies - 1 through 6 (of 6 total)
  • rodleir1963

    (@rodleir1963)

    I have the same problem…

    @dtweney

    This might be to do with expected character encoding, in the plugin class/class-s2-core.php file, in the mail() function, find the following line:
    $message = html_entity_decode( strip_tags( $message ), ENT_NOQUOTES, 'UTF-8' );

    Try replacing it with this:
    $message = strip_tags( html_entity_decode( $message, ENT_NOQUOTES ) );

    Thread Starter dtweney

    (@dtweney)

    @mattyrob

    I think that would just change the encoding. What I really want to do is strip out the nonbreaking spaces.

    But I can try it! I will see if that helps.

    Thread Starter dtweney

    (@dtweney)

    Actually, the code looks a little different in my version, and it seems to be UTF-8 encoding the text already. Relevant lines:

    			$message = html_entity_decode($message, ENT_NOQUOTES, 'UTF-8');
    			$message = wordwrap(strip_tags($message), $this->word_wrap, "\n");

    And that sorta makes sense, because those B! thingies seems like something that might appear when a one-byte character set tries to interpret two-byte unicode.

    So I’m going to try changing that UTF-8 into ISO-8859-1.

    Will report back.

    @dtweney

    I think it might work, try the following on a page on your site:

    $string = "  ";
    var_dump( $string );
    var_dump( html_entity_decode( $string ) );

    The first should report the string length as 12 and hopefully the latter should report the string length lower.

    Thread Starter dtweney

    (@dtweney)

    OK, so in the class-s2-core.php file, I changed:

    $message = html_entity_decode($message, ENT_NOQUOTES, 'UTF-8');
    $message = wordwrap(strip_tags($message), $this->word_wrap, "\n");

    to

    $message = html_entity_decode($message, ENT_NOQUOTES, 'ISO-8859-1');
    $message = wordwrap(strip_tags($message), $this->word_wrap, "\n");

    And it seems to have worked! No more “B!” appearing in place of nonbreaking spaces in some mail clients!

    I will continue to monitor to see if this breaks anything else, but for now it seems to have done the trick.

    Dylan.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Nonbreaking spaces appearing oddly in plain text excerpts’ is closed to new replies.