Plugin Directory

Changeset 778160


Ignore:
Timestamp:
09/25/2013 07:05:01 AM (13 years ago)
Author:
codebykat
Message:

Replace smartquotes and other weirdness.
Fixes http://wordpress.org/support/topic/post-gets-cutoff-when-a-single-quotation-mark-is-used-in-the-body

File:
1 edited

Legend:

Unmodified
Added
Removed
  • post-by-email/trunk/class-post-by-email.php

    r777233 r778160  
    679679        $content = trim( $content );
    680680
    681         // fix for   which get turned into unicode and destroy everything
    682         $content = str_replace( chr( 0xA0 ), ' ', $content );
     681        // fix up special characters which get turned into unicode and destroy everything
     682        // via http://stackoverflow.com/questions/12007613/devilish-curly-quotes
     683
     684        // First, replace UTF-8 characters.
     685        $content = str_replace(
     686            array(
     687                "\xe2\x80\x98",
     688                "\xe2\x80\x99",
     689                "\xe2\x80\x9c",
     690                "\xe2\x80\x9d",
     691                "\xe2\x80\x93",
     692                "\xe2\x80\x94",
     693                "\xe2\x80\xa6",
     694            ),
     695            array( "'", "'", '"', '"', '-', '--', '...' ),
     696            $content
     697        );
     698
     699        // Next, replace their Windows-1252 equivalents... and non-breaking spaces
     700        $content = str_replace(
     701            array( chr( 145 ), chr( 146 ), chr( 147 ), chr( 148 ), chr( 150 ), chr( 151 ), chr( 133 ), chr( 0xA0 ) ),
     702            array( "'", "'", '"', '"', '-', '--', '...', ' ' ),
     703            $content
     704        );
    683705
    684706        return $content;
Note: See TracChangeset for help on using the changeset viewer.