cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Special characters and UTF-8

From: Ralph Seward <rj_seward_at_hotmail.com>
Date: Tue, 4 Dec 2007 20:53:20 +0000

Or, to replace special characters that have an ascii counterpart...
Ralph

for($i=0;$i < strlen($content);$i++){
    $n = ord(substr($content,$i,1));
    if($n > 127){ // $n < 32 ||
        echo "char outside of ASCII.\n";
        if($n == 160){ // non-breaking space
            $content = str_replace(chr(160)," ",$content);
        }
        elseif($n == 145 || $n == 146){ // single quote
            $content = str_replace(substr($content,$i,1), "'", $content);
        }
        elseif($n == 147 || $n == 148 || $n == 180){ // double quotes
            $content = str_replace(substr($content,$i,1), '"', $content);
        }
        elseif($n == 150 || $n == 151 || $n == 173){ // dashes of various lengths
            $content = str_replace(substr($content,$i,1), "-", $content);
        }
        elseif($n == 133){ // elipse
            $content = str_replace(substr($content,$i,1), "...", $content);
        }
        elseif($n == 174){ // copyright mark
            $content = str_replace(substr($content,$i,1), " (copyright) ", $content);
        }
        else{ // any other weird characters
            $content = str_replace(substr($content,$i,1), "", $content);
        }
    }
}

_________________________________________________________________
Your smile counts. The more smiles you share, the more we donate.  Join in.
www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-12-04