NYCPHP Meetup

NYPHP.org

[nycphp-talk] Charsets are still driving me nuts

Daniel Convissor danielc at analysisandsolutions.com
Tue Feb 26 19:06:45 EST 2008


Hi Cliff:

On Tue, Feb 26, 2008 at 05:46:15PM -0500, Cliff Hirsch wrote:
> It?s amazing how many people cut and paste from MS Word.

Tell me about it.  Here's what we use:

function replace_fancy_characters($in) {
    static $search, $replace;

    if (isset($search) == false) {
        $search = array(
            '/\x96/',
            '/\x97/',
            '/\x91/',
            '/\x92/',
            '/\x93/',
            '/\x94/',
            '/\x85/',
            '/\x95/',
            '/\x09/',
            '/\xBC/',
            '/\xBD/',
            '/\xBE/',
        );

        $replace = array(
            '-',
            '--',
            "'",
            "'",
            '"',
            '"',
            '...',
            '*',
            ' ',
            '1/4',
            '1/2',
            '3/4',
        );
    }
    return preg_replace($search, $replace, $in);
}


See you,

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list